前端之家收集整理的这篇文章主要介绍了
(CentOS 7)Docker:安装&配置,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
安装docker
说明:此次安装没有根据官网安装教程的步骤进行,而是直接yum install安装。
- 安装docker
yum install docker
- 关闭防火墙
service firewalld stop
- 启动服务
service docker start
- 设置开机启动
systemctl enable docker
配置docker
说明:swarm是通过Dockerapi而进行docker管理的,所以需要将docker的rest api启动。
Centos docker配置文件位置:/etc/sysconfig/docker
Ubuntu docker配置文件位置:/etc/default/docker
<code class="hljs ruleslanguage has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; Box-sizing: border-Box; font-family: 'Source Code Pro',monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-built_in" style="color: rgb(102,102); Box-sizing: border-Box;">OPTIONS</span>=<span class="hljs-string" style="color: rgb(0,136,0); Box-sizing: border-Box;">'-H tcp://0.0.0.0:[docker_port] -H unix:///var/run/docker.sock --selinux-enabled'</span></code><ul class="pre-numbering" style="Box-sizing: border-Box; position: absolute; width: 50px; background-color: rgb(238,238,238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221,221,221); list-style: none; text-align: right;"><li style="Box-sizing: border-Box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="Box-sizing: border-Box; position: absolute; width: 50px; background-color: rgb(238,221); list-style: none; text-align: right;"><li style="Box-sizing: border-Box; padding: 0px 5px;">1</li></ul>
将docker_port换成想要配置且未被占用的端口号,比如2375.
<code class="hljs has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; Box-sizing: border-Box; font-family: 'Source Code Pro',monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">service docker restart</code><ul class="pre-numbering" style="Box-sizing: border-Box; position: absolute; width: 50px; background-color: rgb(238,85); font-family:'microsoft yahei'; font-size:14px"> 此时看下ps -ef | grep docker
可以看到docker进程的启动项-H tcp://0.0.0.0:2375