码迷,mamicode.com
首页 > 其他好文 > 详细

docker-ce install on CentOS7-mini

时间:2018-06-25 16:49:55      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:ocs   for   比较   hat   group   systemctl   页面跳转   dev   clu   

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

1 Set up the repository

# Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.

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

# Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.

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/文件夹。

# Optional: Enable the edge and test repositories. These repositories are included in the docker.repo file above but are disabled by default. You can enable them alongside the stable repository.

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

# You can disable the edge or test repository by running the yum-config-manager command with the --disable flag. To re-enable it, use the --enable flag. The following command disables the edge and test repository.

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

2 Install Docker CE

# Install the latest version of Docker CE, or go to the next step to install a specific version:

1 yum install docker-ce

//Docker is installed but not started. The docker group is created, but no users are added to the group.

# To install a specific version of Docker CE, list the available versions in the repo, then select and install:

# 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

//The list returned depends on which repositories are enabled, and is specific to your version of CentOS (indicated by the .el7 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 (-), for example, docker-ce-18.03.0.ce.

1 yum install docker-ce-<VERSION STRING>

eg.

1 yum install docker-ce-18.03.1.ce

//Docker is installed but not started. The docker group is created, but no users are added to the group.

3 Start Docker

1 systemctl enable docker
2 systemctl start dokcer

//enable to start with system boot.

4 Verify Docker

# Verify that docker is installed correctly by running the hello-world image.

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) 页面跳转后点击立即使用,此时需要登录,如果没有可以免费注册。

3)  按照页面提示配置Docker加速器(每个人的link不一样)

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

标签:ocs   for   比较   hat   group   systemctl   页面跳转   dev   clu   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!