ubuntu articles --- ubuntu install docker, nvidia-docker and doker-compose

ubuntu articles --- ubuntu install docker, nvidia-docker and doker-compose

1. Install docker

  • 1.1 Uninstall the old version

The docker library comes with ubuntu, so there is no need to add new sources.
But the version of docker that comes with ubuntu is too low, you need to uninstall the old one first and then install the new one

sudo apt-get remove docker docker-engine docker.io containerd runc
  • 1.2 Get the latest software source
sudo apt-get update
  • 1.3 Install apt dependencies

Used to fetch repositories via HTTPS

sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
  • 1.4 Install GPG certificate
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

insert image description here

  • 1.5 Verification
sudo apt-key fingerprint 0EBFCD88

insert image description here

  • 1.6 Test docker installation is successful
sudo docker run hello-world

Two, nvidia-docker installation

  • 2.1 Uninstall nvidia-docker and other GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{
    
    } -n1 docker ps -q -a -f volume={
    
    } | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker
  • 2.2 Add warehouse pack
$ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ 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

insert image description here

  • 2.3 Install nvidia-docker2
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd
  • 2.4 Test and install nvidia-docker successfully (note that you choose your own cuda version)
docker run --runtime=nvidia --rm nvidia/cuda:10.1-base nvidia-smi

3. docker-compose installation

https://docs.docker.com/compose/install/standalone/official website
insert image description here

  • 3.1 Executing commands
curl -SL https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

hint:
如果是普通用户,没有权限,需要切换到root用户:sudo -i

  • 3.2 Authorization
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
  • 3.3 view
docker-compose -v

Error:

root@ubuntu-003:~# docker-compose --version
/usr/local/bin/docker-compose: line 1: html: No such file or directory
/usr/local/bin/docker-compose: line 2: syntax error near unexpected token `<'
'usr/local/bin/docker-compose: line 2: `<head><title>502 Bad Gateway</title></head>

Solution:
You need to download the package in advance

sudo mv ./docker-compose-linux-x86_64 /usr/local/bin/docker-compose
sudo chmod a+x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo docker-compose -v

Guess you like

Origin blog.csdn.net/m0_46825740/article/details/131091407