Ubuntu18.04 安装Docker

1.查看ubuntu版本

master@master:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04 LTS"

2.查看系统内核版本
ps:不管Ubuntu的哪个版本,Docker需要64的操作系统,此外你的kernel内核至少要在3.10版本之上

master@master:~$ uname -a
Linux master 4.15.0-20-generic #21-Ubuntu SMP Tue Apr 24 06:16:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

3.先卸载可能存在的旧版本

master@master:~$ sudo apt-get remove docker docker-engine docker.io containerd runc

4.更新系统apt包

master@master:~$ sudo apt-get update

5.安装 apt 依赖包,用于通过HTTPS来获取仓库:

master@master:~$ sudo apt-get install apt-transport-https \ ca-certificates \ curl \ software-properties-common

6.添加Docker官方的GPG密钥:

master@master:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

7、设置稳定版仓库

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

8.再次更新api

master@master:~$ sudo apt-get update

9.安装 Docker Engine-Community 和 containerd
选择1 :安装最新版本的 Docker Engine-Community 和 containerd

    master@master:~$  sudo apt-get install docker-ce docker-ce-cli containerd.io

选择2:2.1安装特定版本的 Docker Engine-Community

master@master:~$  apt-cache madison docker-ce
docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
docker-ce | 18.06.1~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
docker-ce | 18.06.0~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
  ...

2.2 使用第二列中的版本字符串安装特定版本,例如 18.06.1~ ce~3-0 ~ubuntu,VERSION_STRING = 18.06.1~ ce~ 3-0~ubuntu 即可(这里~后面加了空格,不然简书显示有问题,注意复制上面的字符串)

master@master:~$  sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io

10.测试 Docker 是否安装成功,输入以下指令,打印出以下信息则安装成功:

master@master:~$  docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容