This is a Docker image for the Espressif IoT Development Framework (ESP-IDF). It is intended for building applications and libraries with specific versions of ESP-IDF, when doing automated builds.
This image contains a copy of ESP-IDF and all the tools necessary to build ESP-IDF projects.
This build will create a user to work with. If you do not specify the username it will default to esp32_user, You can set the username by building with --build-arg USERNAME=username this user will be UID 1000. This is so that if you mount directories on ubuntu it will get UID 1000 which is usually a real user (The first user created)
In order to build some of the things I build you will need the /home/USERNAME directory, so I usually do a docker volume create volume_name_home_username and then use that to mount the docker home directory.
docker build . --build-arg USERNAME=username -t esp-idf:v5.1.2
I usually run bash and then cd to a source directory and do my build. I mount /dev/bus/usb so I can use the /dev/ttyUSBx devices to program the ESP32.
here is the basic command I use:
docker run --rm --privileged -v /dev/bus/usb:/dev/bus/usb \
-v esp32_home_dir_username:/home/username -v ~/src:/home/mlw/src \
-it esp-idf:v5.1.2 bash
If you need to be root you can change bash to
docker run --rm --privileged -v /dev/bus/usb:/dev/bus/usb \
-v esp32_home_dir_username:/home/username -v ~/src:/home/username/src \
-it esp-idf:v5.1.2 sudo bash
This should work, I have not tested it.
Build a project located in the current directory using idf.py build
command:
docker run --rm -v $PWD:/project -w /project esp-idf:v5.1.2 idf.py build