docker开启远程端口的坑

为了开启docker远程端口真是难受
google了无数条,全差不多,因为有几种修改方式,所以都尝试过
这里修改点,哪里修改点,搞得回不去了

首先指明要修改的点

  1. 云服务器要开放docker的端口 可自定义端口
  2. /usr/lib/systemd/system/docker.service 文件 修改 ExecStart 处
  3. 读取 systemctl daemon-reload 重启 systemctl restart docker

查看docker状态

sudo systemctl status docker.service
 sudo systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2020-06-23 18:50:58 CST; 38s ago
     Docs: http://docs.docker.com
  Process: 16400 ExecStart=/usr/bin/docker-current daemon --tls=false -H unix:///var/run/docker.sock -H tcp://0.0.0.0:9876 --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY (code=exited, status=1/FAILURE)
 Main PID: 16400 (code=exited, status=1/FAILURE)

Jun 23 18:50:58 VM_0_11_centos systemd[1]: Starting Docker Application Container Engine...
Jun 23 18:50:58 VM_0_11_centos docker-current[16400]: Command "daemon" is deprecated, and will be removed in Docker 1.16. Please run `dockerd` directly.
Jun 23 18:50:58 VM_0_11_centos docker-current[16400]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the c...docker.sock])
Jun 23 18:50:58 VM_0_11_centos systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jun 23 18:50:58 VM_0_11_centos systemd[1]: Failed to start Docker Application Container Engine.
Jun 23 18:50:58 VM_0_11_centos systemd[1]: Unit docker.service entered failed state.
Jun 23 18:50:58 VM_0_11_centos systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

英语水平太差不过看到了

unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the c...docker.sock])

然后我就 vim /etc/docker/daemon.json 查看发现有之前的配置没有删除
删除之后就好了
/usr/lib/systemd/system/docker.service 的修改处

ExecStart=/usr/bin/docker-current daemon --tls=false -H unix:///var/run/docker.sock  -H tcp://192.168.18.183:2375  \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY

tcp 处 自行修改

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值