Docker在Ubuntu的安装

版权声明:分享才能发挥最大的价值 https://blog.csdn.net/qq_32252957/article/details/81874989

docker在企业服务部署中普遍使用,因此有必要掌握基本的docker使用方法,下面我给大家介绍docker的基本安装

ubuntu 的Docker CE安装

docker ee: 企业版安装文档https://www.docker.com/enterprise-edition/
docker ce: 客户版安装文档https://docs.docker.com/install/linux/docker-ce/ubuntu/

大家可以看官方文档的安装,我这里只简单演示ubuntu系统上ce版本的安装
To install Docker CE, you need the 64-bit version of one of these Ubuntu versions:
Bionic 18.04 (LTS)
Artful 17.10
Xenial 16.04 (LTS)
Trusty 14.04 (LTS)
安装ce, 你需要ubuntu 64位的上面的版本

卸载旧版本 
sudo apt-get remove docker docker-engine docker.io

安装之前,需要建立Docker仓库,以后安装和更新都从这些仓库来更新
1. sudo apt-get update
安装包允许apt通过https协议使用仓库
2. sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common
加入官方的GPGkey
3.curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
确认指纹钥匙是否正确
4.$ sudo apt-key fingerprint 0EBFCD88

pub   4096R/0EBFCD88 2017-02-22
      Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid                  Docker Release (CE deb) <[email protected]>
sub   4096R/F273FCD8 2017-02-22
建立稳定仓库
5.$ sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

安装Docker ce
1.$ sudo apt-get update
安装最新版本的Docker ce 或者使用下一步来安装确定的版本
2.$ sudo apt-get install docker-ce
安装确定版本的docker ce
3.
列出仓库中可用的版本
a.$ apt-cache madison docker-ce
下面是我的结果
 docker-ce | 18.06.0~ce~3-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 18.03.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.12.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.12.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.09.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.09.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.06.2~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.06.1~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.06.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.03.2~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.03.1~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
 docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
b.安装确定的版本,使用全名 eg: docker-ce=18.03.0~ce-0~ubuntu
4.确定Dockerce安装成功
这个命令下载一个测试的image镜像,并在一个容器中运行,当容器运行,打印出信息并退出
$ sudo 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/engine/userguide/
 

猜你喜欢

转载自blog.csdn.net/qq_32252957/article/details/81874989