代码改变世界

安装Docker

2019-11-24 20:01  那个杰克  阅读(185)  评论(0编辑  收藏  举报
服务器环境:CentOS7
+ 例外: 如果之前安装有docker,需要先移除旧版本:
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
  • 步骤1:
    安装必要的系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

  • 步骤2:
    通过添加外源,安装稳定的仓库:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

  • 步骤3:
    安装DockerCE
sudo yum install docker-ce docker-ce-cli containerd.io

如果安装过程中,有提示GPG KEY秘钥,确认您现在已经拥有指纹 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35 的密钥相同。

选择yes

查看在你的仓库中可用的docker版本

yum list docker-ce --showduplicates | sort -r

docker-ce.x86_64  3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64  3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64  18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64  18.06.0.ce-3.el7                    docker-ce-stable

安装:

注意:填写你要安装版本 例如:docker-ce-18.09.1
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io

  • 步骤4:
    Start Docker
sudo systemctl start docker
  • 步骤5:
    通过运行docker run hello-world验证Docker CE是否已经正确的安装
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/

``