Docker on Jetson
Back to Module 3 | Back to Table of Contents
13. Install Docker and Basic Use
Introduction
Docker is a lightweight container platform that packages an application and all its dependencies into portable containers. It helps you run the same environment in development, testing, and production with much less configuration drift.
Docker improves consistency by using process isolation, fast startup, and efficient resource usage. It is well suited for local development, server deployment, and multi-service AI pipelines.
Install Docker on Jetson
1. Install Docker CE
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-commonAdd Docker GPG key and repository (example below uses Aliyun mirror):
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /usr/share/keyrings/docker-ce.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-ce.gpg] \
https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.ioVerify Docker installation:
docker --version
Add your user to the docker group (restart shell or run newgrp):
sudo usermod -aG docker "$USER"
newgrp dockerAfter this, you can run Docker commands without sudo.
2. Install NVIDIA Container Toolkit
distribution=$(. /etc/os-release; echo "$ID$VERSION_ID")
curl -s -L https://nvidia.github.io/libnvidia-container/gpgkey \
| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
| sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
Install toolkit:
sudo apt update
sudo apt install -y nvidia-container-toolkitEnable GPU runtime for Docker:
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart dockerVerify GPU access inside a container:
sudo docker run --rm --runtime=nvidia --gpus all --network host ubuntu nvidia-smiIf network restrictions exist in your environment, use a mirror/proxy when pulling images or packages.
3. Manual installation (APT unavailable)
If Docker CE cannot be installed from the Ubuntu repository, download .deb packages manually from:
https://download.docker.com/linux/ubuntu/dists/
Choose your Ubuntu version:
| Ubuntu Version | Code | Example folder |
|---|---|---|
| Ubuntu 20.04 LTS | focal | dists/focal/pool/stable/ |
| Ubuntu 22.04 LTS | jammy | dists/jammy/pool/stable/ |
| Ubuntu 24.04 LTS | noble | dists/noble/pool/stable/ |
Then select your architecture folder:
amd64: x86_64 (Server / PC)arm64: ARM 64-bit, including Jetsonarmhf: ARM 32-bits390x: IBM z systems
Download the five matching packages:
containerd.io_<version>_<arch>.debdocker-ce_<version>_<arch>.debdocker-ce-cli_<version>_<arch>.debdocker-buildx-plugin_<version>_<arch>.debdocker-compose-plugin_<version>_<arch>.deb
Install them from the folder where you downloaded the files:
sudo dpkg -i ./containerd.io_<version>_<arch>.deb \
./docker-ce_<version>_<arch>.deb \
./docker-ce-cli_<version>_<arch>.deb \
./docker-buildx-plugin_<version>_<arch>.deb \
./docker-compose-plugin_<version>_<arch>.debIf dependencies are missing, run:
sudo apt -f installCheck Docker service status:
sudo systemctl status dockerIf Docker is not running:
sudo systemctl start dockerDocker Basics
The Docker Engine provides the Docker CLI (docker), which lets you manage images, containers, networks, and storage from the command line.
Before learning common commands, review these two core concepts:
- Image: A read-only template that contains the base OS, runtime, libraries, and app code needed to run a container.
- Container: A running instance created from an image; it has its own process and environment, and can be started/stopped independently.
In short:
A Docker image is like an installation package, while a container is a running program instance.
Common commands
1) Show Docker info
docker info2) Show Docker version
docker --version3) Pull image
docker pull <image_name>If no tag is specified, Docker pulls latest by default.
docker pull <image_name>:<tag>4) Run image
docker run <image_name>Run a specific image interactively:
docker run -it ubuntu:18.04 /bin/bashExit a running container by typing exit.
4.1) List running containers
docker ps4.2) List all containers
docker ps -a5) Remove stopped containers
docker container prune6) List local images
docker images7) Remove an image
Remove only after stopping and deleting related containers.
docker rmi <image_name>8) Save a container as a new image
docker commit <container_id> <new_image_name>:<tag>Choose a name and tag according to the actual container ID.
9) Stop a container
docker stop <container_id_or_name>