hopeless-dream

导航

Ubuntu安装docker

官方文档地址:https://docs.docker.com/engine/install/ubuntu/

步骤

卸载老版本

$ sudo apt-get remove docker docker-engine docker.io containerd runc

更新yum源

$ sudo apt-get update
$ sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

添加官方GPG key

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

设置稳定版的源

$ echo \
  "deb [arch=amd64 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

安装docker engine

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

如果需要安装特定版本的docker engine,需要使用如下命令

$ apt-cache madison docker-ce
 docker-ce | 5:18.09.0~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.3~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.2~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages
 docker-ce | 18.03.1~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages

安装特定版本,如18.03.1~ce~3-0~ubuntu

$ sudo apt-get install docker-ce=5:18.09.0~3-0~ubuntu-bionic docker-ce-cli=5:18.09.0~3-0~ubuntu-bionic containerd.io

运行hello world ,测试是否安装正确

$ sudo docker run hello-world

启动docker

root@docker:~# systemctl start docker

root@docker:~# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-06-05 16:50:05 UTC; 10min ago
     Docs: https://docs.docker.com
 Main PID: 39588 (dockerd)
    Tasks: 11
   CGroup: /system.slice/docker.service
           └─39588 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

卸载docker

$ sudo apt-get purge docker-ce docker-ce-cli containerd.io

 

posted on 2021-06-06 00:59  hopeless-dream  阅读(63)  评论(0编辑  收藏  举报