Docker

Ubuntu / Linux Setup

Setting up Docker on Ubuntu is generally the smoothest experience for embedded development because it runs natively on Linux without a virtual machine layer.


Install Docker Engine

We recommend installing Docker Engine using the official Docker APT repository to ensure you get the latest version.

1. Set up the repository

Update your package index and install packages to allow apt to use a repository over HTTPS:

bash
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

Add Docker's official GPG key:

bash
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Set up the repository:

bash
echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

2. Install Docker Engine

bash
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Post-Installation: Manage Docker as a non-root user

By default, the docker command can only be run by the root user or a user in the docker group. To avoid having to type sudo before every Docker command, add your user to the docker group.

bash
sudo usermod -aG docker $USER

Log out and log back in

Log out and log back in (or restart your computer) so that your group membership is re-evaluated. If you don't do this, you will still get a permission denied error.


Verify Installation

Run the hello-world image to verify Docker is installed and you can run it without sudo:

bash
docker run hello-world

Passing USB Devices to Docker Containers

Because Docker runs natively on Linux, passing USB devices (like an ESP32 or ST-LINK) into the container is straightforward. You simply use the --device flag when running the container.

For example, if your ESP32 is connected at /dev/ttyUSB0:

bash
docker run --rm -it --device=/dev/ttyUSB0 espressif/idf idf.py flash

Important: Permissions

Inside the container, the user running the toolchain must have permission to access the device file. Usually, this means the container user needs to be in the dialout group, just like on the host machine.

Make sure your host user is in the dialout group:

bash
sudo usermod -aG dialout $USER

Next Steps

Learn how to define and run complex environments using Docker Compose.

Previous
Windows Setup