docker开启远程访问 2375

docker开启远程访问

系统使用centos7

一、打开docker端口

/usr/lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd-current \
#增加-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock  重启docker
ExecStart=/usr/bin/dockerd-current -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock \

之后重启docker让配置生效。
即可通过http方式和docker -H方式访问docker

二、命令测试

134上运行的容器

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
4f191cbd3c26        redis               "docker-entrypoint..."   6 months ago        Up 9 hours          0.0.0.0:6379->6379/tcp   some-redis
6de8887c05fa        mysql               "docker-entrypoint..."   6 months ago        Up 9 hours          0.0.0.0:3308->3306/tcp   mysql8
60d325c743c4        mysql-57            "container-entrypo..."   6 months ago        Up 9 hours          0.0.0.0:3306->3306/tcp   mysql57

134已打开远程端口。通过137查看134的容器和137自己的容器

[root@docker137 ~]# docker -H 192.168.72.134 ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
4f191cbd3c26        redis               "docker-entrypoint..."   6 months ago        Up 9 hours          0.0.0.0:6379->6379/tcp   some-redis
6de8887c05fa        mysql               "docker-entrypoint..."   6 months ago        Up 9 hours          0.0.0.0:3308->3306/tcp   mysql8
60d325c743c4        mysql-57            "container-entrypo..."   6 months ago        Up 9 hours          0.0.0.0:3306->3306/tcp   mysql57
[root@docker137 ~]# docker ps
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS                        PORTS                       NAMES
d9f65ddf94eb        vmware/nginx-photon:v1.5.1         "nginx -g 'daemon ..."   6 months ago        Restarting (1) 30 hours ago                               nginx
4b363df62d6a        vmware/harbor-adminserver:v1.5.1   "/harbor/start.sh"       6 months ago        Up 34 hours (healthy)                                     harbor-adminserver
fd13295da8db        vmware/harbor-db:v1.5.1            "/usr/local/bin/do..."   6 months ago        Up 34 hours (healthy)         3306/tcp                    harbor-db
46fd5560d00e        vmware/harbor-log:v1.5.1           "/bin/sh -c /usr/l..."   6 months ago        Up 34 hours (healthy)         127.0.0.1:1514->10514/tcp   harbor-log

136服务器未打开端口,响应错误提示信息

    [root@localhost ~]#  docker -H 192.168.72.136 ps
    error during connect: Get http://192.168.72.136:2375/v1.26/containers/json: dial tcp 192.168.72.136:2375: getsockopt: no route to host

其他参考

实践一下,用IDEA自动化部署Docker镜像,并没有你想象中的那么难
https://blog.csdn.net/x275920/article/details/124666224

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值