Image using the Debian and Arduino CLI to program Arduino, ESP32, and ESP8266 boards.
1.3K
This image provides the Arduino CLI inside a Docker container, allowing you to compile sketches, manage board packages, test projects, and upload firmware without installing Arduino CLI on your host system.
compile, upload)The Dockerfiles used to build the images are available at:
https://github.com/ajg555/arduino-cli-dockerfiles
Official Arduino CLI repository:
https://github.com/arduino/arduino-cli
Official Arduino CLI documentation:
https://docs.arduino.cc/arduino-cli/getting-started
Create a persistent container:
docker container run \
-it \
--name arduino \
--entrypoint bash \
-v ~/projects:/root/Arduino/projects \
--privileged \
-v /dev:/dev \
ajg555/arduino-cli
Reconnect later:
docker container start -ai arduino
docker container run --rm -it --name arduino ajg555/arduino-cli --help
docker container run --rm -it --name arduino ajg555/arduino-cli core list
This allows you to use Arduino CLI as if it were installed locally.
docker container run \
--rm \
-it \
-v ~/my-codes:/my-codes \
--device=/dev/ttyUSB0 \
--entrypoint bash \
--name arduino \
ajg555/arduino-cli
To simplify usage, add the following alias to your ~/.bashrc:
alias arduino-dk="docker container run --rm -it \
-v ~/my-codes:/my-codes \
--entrypoint bash \
--name arduino \
ajg555/arduino-cli"
Example:
$ arduino-dk
root@0353861fa74d:~/Arduino#
docker container run \
-it \
--name arduino \
--entrypoint bash \
-v ~/projects:/root/Arduino/projects \
--privileged \
-v /dev:/dev \
ajg555/arduino-cli
docker container start -ai arduino
The helper commands use two environment variables:
BOARD – Arduino board FQBN (Fully Qualified Board Name)PORT – Serial port used for uploadsecho $BOARD
echo $PORT
Example:
esp32:esp32:esp32
/dev/ttyACM0
These values are defined by default in the Docker image and can be changed during the current shell session.
For example, to use an ESP32 Dev Module:
export BOARD=esp32:esp32:esp32
For an ESP32-S3:
export BOARD=esp32:esp32:esp32s3
For an ESP32-C3:
export BOARD=esp32:esp32:esp32c3
For an ESP32-C6:
export BOARD=esp32:esp32:esp32c6
For an Arduino Uno:
export BOARD=arduino:avr:uno
For devices detected as /dev/ttyUSB0:
export PORT=/dev/ttyUSB0
For devices detected as /dev/ttyACM0:
export PORT=/dev/ttyACM0
List the available serial devices:
ls /dev/ttyUSB* /dev/ttyACM* 2>/dev/null
You can also use Arduino CLI to identify connected boards:
arduino-cli board list
Example:
Port Protocol Type Board Name FQBN Core
/dev/ttyACM0 serial Serial Port (USB) Unknown
/dev/ttyS0 serial Serial Port Unknown
The detected port can then be assigned to PORT, and the reported FQBN can be assigned to BOARD.
The image provides helper commands:
compile – compile the current sketchupload – compile and upload the sketch using the configured BOARD and PORTcd ~/Arduino/projects/examples/WiFiScan
compile
Example output:
Sketch uses 883563 bytes (67%) of program storage space. Maximum is 1310720 bytes.
Global variables use 43968 bytes (13%) of dynamic memory, leaving 283712 bytes for local variables. Maximum is 327680 bytes.
upload
Example output:
Sketch uses 883563 bytes (67%) of program storage space. Maximum is 1310720 bytes.
Global variables use 43968 bytes (13%) of dynamic memory, leaving 283712 bytes for local variables. Maximum is 327680 bytes.
esptool v5.1.0
Connected to ESP32 on /dev/ttyACM0:
Chip type: ESP32-D0WDQ6-V3 (revision v3.1)
Features: Wi-Fi, BT, Dual Core + LP Core, 240MHz, Vref calibration in eFuse, Coding Scheme None
Crystal frequency: 40MHz
MAC: xx:xx:xx:xx:xx:xx
Stub flasher running.
Changing baud rate to 921600...
Changed.
Configuring flash size...
Flash will be erased from 0x00001000 to 0x00007fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Flash will be erased from 0x00010000 to 0x000e7fff...
Wrote 25184 bytes (16080 compressed) at 0x00001000 in 0.7 seconds (274.0 kbit/s).
Hash of data verified.
Wrote 3072 bytes (146 compressed) at 0x00008000 in 0.1 seconds (351.7 kbit/s).
Hash of data verified.
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (472.7 kbit/s).
Hash of data verified.
Wrote 883712 bytes (567786 compressed) at 0x00010000 in 9.7 seconds (729.1 kbit/s).
Hash of data verified.
Hard resetting via RTS pin...
New upload port: /dev/ttyACM0 (serial)
Clone the repository and build the image:
git clone https://github.com/ajg555/arduino-cli-dockerfiles.git
cd arduino-cli-dockerfiles
docker build -t arduino-cli .
This image includes the following cores:
arduino:avr 1.8.6
arduino:esp32 2.0.18-arduino.5
esp32:esp32 3.3.4
esp8266:esp8266 3.1.2
Preinstalled Arduino libraries include:
AceButton
Adafruit BME280 Library
Adafruit BusIO
Adafruit GFX Library
Adafruit SSD1306
Adafruit Unified Sensor
ArduinoJson
AsyncTCP
DHT sensor library
ESP Async WebServer
EspMQTTClient
LoRa
RadioHead
RadioLib
TinyGPS++
TinyGSM
U8g2
WiFiManager
TFT_eSPI
OneWire
PID
PubSubClient
Full list available via:
arduino-cli lib list
--privileged for reliable device access.BOARD and PORT are session-based environment variables.Content type
Image
Digest
sha256:e99cab074…
Size
3.6 GB
Last updated
3 months ago
docker pull ajg555/arduino-cli