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

bash
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

Add Docker GPG key and repository (example below uses Aliyun mirror):

bash
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.io

Verify Docker installation:

bash
docker --version

Docker installed

Add your user to the docker group (restart shell or run newgrp):

bash
sudo usermod -aG docker "$USER"
newgrp docker

After this, you can run Docker commands without sudo.

2. Install NVIDIA Container Toolkit

bash
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

NVIDIA Container Toolkit

Install toolkit:

bash
sudo apt update
sudo apt install -y nvidia-container-toolkit

Enable GPU runtime for Docker:

bash
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Verify GPU access inside a container:

bash
sudo docker run --rm --runtime=nvidia --gpus all --network host ubuntu nvidia-smi

If 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 VersionCodeExample folder
Ubuntu 20.04 LTSfocaldists/focal/pool/stable/
Ubuntu 22.04 LTSjammydists/jammy/pool/stable/
Ubuntu 24.04 LTSnobledists/noble/pool/stable/

Then select your architecture folder:

  • amd64: x86_64 (Server / PC)
  • arm64: ARM 64-bit, including Jetson
  • armhf: ARM 32-bit
  • s390x: IBM z systems

Download the five matching packages:

  • 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>.deb

Install them from the folder where you downloaded the files:

bash
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>.deb

If dependencies are missing, run:

bash
sudo apt -f install

Check Docker service status:

bash
sudo systemctl status docker

If Docker is not running:

bash
sudo systemctl start docker

Docker 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

bash
docker info

2) Show Docker version

bash
docker --version

3) Pull image

bash
docker pull <image_name>

If no tag is specified, Docker pulls latest by default.

bash
docker pull <image_name>:<tag>

4) Run image

bash
docker run <image_name>

Run a specific image interactively:

bash
docker run -it ubuntu:18.04 /bin/bash

Exit a running container by typing exit.

4.1) List running containers

bash
docker ps

4.2) List all containers

bash
docker ps -a

5) Remove stopped containers

bash
docker container prune

6) List local images

bash
docker images

7) Remove an image

Remove only after stopping and deleting related containers.

bash
docker rmi <image_name>

8) Save a container as a new image

bash
docker commit <container_id> <new_image_name>:<tag>

Choose a name and tag according to the actual container ID.

9) Stop a container

bash
docker stop <container_id_or_name>

Back to Module 3