ubuntu-18.04.6 安装 docker

  • Post author:
  • Post category:其他


  1. 先卸载旧版,如果没有的话,就不用执行了,直接第二步。

sudo apt-get update
sudo apt-get remove docker docker-engine docker.io containerd runc
  1. 在终端输入

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg lsb-release
  1. 安装证书

curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
  1. 写入软件源信息

sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"

如果此处报错:

ubuntu add-apt-repository command not found

解决的方法安装software-properties-common

apt-get install software-properties-common
  1. 安装

sudo apt-get install docker-ce docker-ce-cli containerd.io


如果报错:

Package docker-ce is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source

打开 /etc/apt/sources.list.d/

docker

.list 中添加下面内容

deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
  1. 启动docker

systemctl start docker
  1. 安装工具

apt-get -y install apt-transport-https ca-certificates curl software-properties-common
  1. 重启docker

service docker restart
  1. 查看docker版本

sudo docker version



版权声明:本文为WangAnJiao原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。