docker ubuntu安装

首先用下面的命令更新apt 包的索引:

sudo apt-get update

把Docker仓库加进到apt里,反斜杠\代表一行,只是换行写更清晰:

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

添加Docker的官方GPG密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88

建立稳定仓库,若想从边缘或测试存储库安装构建,则在stable之后添加单词edge或test(或两者):

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

接下来正式安装docker:

sudo apt-get update
sudo apt-get install docker-ce

验证docker:

sudo docker run hello-world

安装NVIDIA-Docker:

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \
  sudo apt-key add -
distribution="ubuntu18.04"
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

正式安装NVIDIA-Docker:

sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

验证NVIDIA-Docker:

sudo docker run --runtime=nvidia --rm nvidia/cuda:10.0-base nvidia-smi

你可能感兴趣的:(笔记,docker,ubuntu,容器)