Skip to content

docker

Install docker engine

Please check supported versions first before adding the repository.

sudo apt update && sudo apt install -y ca-certificates curl gnupg lsb-release

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt update && sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin

NVIDIA GPU support

Install the NVIDIA Container Toolkit

curl -fsSL 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
sudo apt update && sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

Test docker installation

sudo docker run hello-world

# nvidia GPU support
sudo docker run --gpus all nvidia/cuda:12.0-base nvidia-smi

(Optional) add to docker group

So you don't have to use sudo on docker commands.

sudo usermod -aG docker $USER

And then log out and log back in.

(Optional) settings for Docker

Edit /etc/docker/daemon.json, add the following entries

/etc/docker/daemon.json
{
  "data-root": "/home/docker",
  "registry-mirrors": ["https://mirror.gcr.io"],
  "storage-driver": "btrfs"
}

Then run the following command to apply new docker daemon settings.

sudo service docker restart

You can see the new settings:

sudo docker info

Documentations and Tutorials for Docker

Docker Utilities

Comments