Docker
Install docker on ubuntu
1.Uninstall old versions
bash sudo apt-get remove docker docker-engine docker.io containerd runc
Check that it has been completely removed from your system:bash docker -v
If the a message likeDocker version 20.10.14, build a224086
is displayed, try following commands to remove it:bash sudo apt-get purge -y docker-engine docker docker.io docker-ce docker-ce-cli sudo apt-get autoremove -y --purge docker-engine docker docker.io docker-ce
The above commands will not remove images, containers, volumes, or user created configuration files on your host. If you wish to delete all images, containers, and volumes run the following commands:bash sudo rm -rf /var/lib/docker /etc/docker sudo rm /etc/apparmor.d/docker sudo groupdel docker sudo rm -rf /var/run/docker.sock
2.Install using the repository
First, make the following configurations to avoid internet problems in the next levels:
bash sudo nano /etc/apt/apt.conf.d/proxy.conf
Then copy and saveAcquire::http::Proxy::download.docker.com "http://fodev.org:8118/";
Update the apt 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 \ lsb-release
Add Docker’s official GPG key:bash curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.bash 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
Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:bash sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io
Install latest version of Docker Engine:bash sudo apt-get install docker-ce
Set proxy to be able of pulling images: ```bash mkdir -p /etc/systemd/system/docker.service.d sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf[Service] Environment="HTTPS_PROXY=http://fodev.org:8118"
systemctl daemon-reload systemctl restart docker
Verify that Docker Engine is installed correctly by running the hello-world image.
bash sudo docker run hello-world ```
3.Add registry-mirror
bash sudo nano /etc/docker/daemon.json
Copy and save
{ "registry-mirrors": [ "https://docker.jamko.ir" ], "insecure-registries": [], "debug": true, "experimental": false }
bash systemctl daemon-reload systemctl restart docker
Installing NVIDIA Container Toolkit for docker
1.Setting up Docker
Docker-CE on Ubuntu can be setup using Docker’s official convenience script:
bash curl https://get.docker.com | sh \ && sudo systemctl --now enable docker
2.Setting up NVIDIA Container Toolkit
Setup the package repository and the GPG key:
bash distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \ && 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/$distribution/libnvidia-container.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
To get access to
experimental
features and access to release candidates, you may want to add theexperimental
branch to the repository listing:bash curl -s -L https://nvidia.github.io/libnvidia-container/experimental/$distribution/libnvidia-container.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
If you got following error:Unsupported distribution! Check https://nvidia.github.io/libnvidia-container
Use the following command to solve it, otherwise ignore this step: ```bash distribution=ubuntu18.04Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit sudo systemctl restart docker ```
Install the nvidia-docker2 package (and dependencies) after updating the package listing:```bash sudo apt-get update
sudo apt-get install -y nvidia-docker2 ``` Restart the Docker daemon to complete the installation after setting the default runtime:
bash sudo systemctl restart docker
At this point, a working setup can be tested by running a base CUDA container:bash sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
This should result in a console output shown below: