在centos7上使用docker远程链接

 

#vim /etc/docker/daemon.json

{
  "registry-mirrors": ["https://cvpqlagp.mirror.aliyuncs.com"]
}
{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}

# vim /usr/lib/systemd/docker.service

修改

ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

如下:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
[Install]
WantedBy=multi-user.target

# systemctl daemon-reload 

 # systemctl restart docker

开放端口

# firewall-cmd --zone=public --add-port=2375/tcp --permanent 

查看是否重启成功 

[root@debug systemd]# docker version                                                                 
Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:10:07 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 08:10:07 2017
 OS/Arch:      linux/amd64
 Experimental: false

查看监听的端口

[root@debug systemd]# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 127.0.0.1:46160         0.0.0.0:*               LISTEN      25663/java          
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      25928/nginx: master 
tcp        0      0 0.0.0.0:81              0.0.0.0:*               LISTEN      25928/nginx: master 
tcp        0      0 0.0.0.0:8082            0.0.0.0:*               LISTEN      25663/java          
tcp        0      0 0.0.0.0:8181            0.0.0.0:*               LISTEN      11532/java          
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      998/sshd            
tcp        0      0 0.0.0.0:23000           0.0.0.0:*               LISTEN      11318/fdfs_storaged 
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      25928/nginx: master 
tcp        0      0 0.0.0.0:8800            0.0.0.0:*               LISTEN      4936/java           
tcp        0      0 0.0.0.0:8801            0.0.0.0:*               LISTEN      6708/java           
tcp        0      0 127.0.0.1:8005          0.0.0.0:*               LISTEN      4936/java           
tcp        0      0 127.0.0.1:8006          0.0.0.0:*               LISTEN      6708/java           
tcp        0      0 0.0.0.0:8009            0.0.0.0:*               LISTEN      4936/java           
tcp        0      0 0.0.0.0:8010            0.0.0.0:*               LISTEN      6708/java           
tcp        0      0 0.0.0.0:22122           0.0.0.0:*               LISTEN      11296/fdfs_trackerd 
tcp6       0      0 :::111                  :::*                    LISTEN      4450/rpcbind        
tcp6       0      0 :::2375                 :::*                    LISTEN      6444/dockerd       

 

转载于:https://my.oschina.net/u/2270256/blog/2218784

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值