docker-ce install on CentOS7-mini

匿名 (未验证) 提交于 2019-12-03 00:34:01

Docker 分为开源免费的 CE(Community Edition)和收费的 EE(Enterprise Edition)。在Docker-CE官方的源中,有stable、edge和test三个版本。本文安装的是免费的docker-ce的stable版本。

1 Set up the repository

yum-utilsyum-config-managerdevice-mapper-persistent-datadevicemapper

1 yum install -y yum-utils device-mapper-persistent-data lvm2

stableedgetest

1 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

//使用yum-config-manager添加docker-ce的源。也可以使用vim或者wget将源放到/etc/yum.repos.d/文件夹。

edgetestdocker.repo

1 yum-config-manager --enable docker-ce-edge 2 yum-config-manager --enable docker-ce-test

edgetestyum-config-managercommand with the--disable--enableedgetest repository.

1 yum-config-manager --disable docker-ce-edge 2 yum-config-manager --disable docker-ce-test

2 Install Docker CE

latest version

1 yum install docker-ce

docker

specific version

# 1) List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:

1 yum list docker-ce --showduplicates | sort 

...

docker-ce.aarch64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.aarch64 18.03.1.ce-1.el7.centos @docker-ce-stable
docker-ce.aarch64 18.03.0.ce-1.el7.centos docker-ce-stable

suffix in this example).

# 2) Install a specific version by its fully qualified package name, which is the package name (docker-ce) plus the version string (2nd column) up to the first hyphen, separated by a hyphen (-docker-ce-18.03.0.ce.

1 yum install docker-ce-<VERSION STRING>

eg.

1 yum install docker-ce-18.03.1.ce

docker

3 Start Docker

1 systemctl enable docker 2 systemctl start dokcer

//enable to start with system boot.

4 Verify Docker

dockerhello-world

1 systemctl status docker 2 docker run hello-world

...

Hello from Docker!
This message shows that your installation appears to be working correctly.

//This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.

# Verify docker via httpd

1 docker run -d -p 80:80 httpd

//上一命令执行的过程如下:

1) 从Docker Hub下载httpd镜像,其中,镜像中已经安装好了Apache HTTP Server。

2) 启动httpd容器,并将容器的80端口映射到host的80端口,前提是host的80端口是可以访问的。

//下面就可以通过浏览器访问host_IP验证httpd容器是否启动正常(输出It works!为正常)。

5 Docker Accelerator

# Docker Hub的服务器在国外,下载镜像会比较慢。DaoCloud、阿里云提供了国内的Docker镜像服务。

# 以DaoCloud为例,配置Docker加速器

1) 访问DaoCloud官网(https://www.daocloud.io/),点击更多->加速器,也可直接访问(https://www.daocloud.io/mirror#accelerator-doc)。

2) 页面跳转后点击立即使用,此时需要登录,如果没有可以免费注册。

1 curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://xxxxxxxx.m.daocloud.io

4) 重新启动Docker

1 systemctl daemon-reload 2 systemctl restart docker

6 Reference

https://docs.docker.com/install/linux/docker-ce/centos/

http://www.cnblogs.com/CloudMan6/p/6727146.html

https://www.daocloud.io/mirror#accelerator-doc

docker-ce install on CentOS7-mini

原文:https://www.cnblogs.com/hxt-lingmo/p/9224400.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!