Set Docker_Opts in centos

后端 未结 12 1674
我在风中等你
我在风中等你 2021-01-31 04:44

I need to set docker to listen to tcp://0.0.0.0/4243 on my host machine running amazon linux (centos). All the documentation I have seen has told me to run the following command

相关标签:
12条回答
  • 2021-01-31 05:17

    I Think on CentOS, you can try setting the options as below in the file /etc/sysconfig/docker

    other_args="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock"
    

    Then restart the docker and try checking if the port is opening using

    netstat -plt | grep 4243 
    

    This should list if listening

    0 讨论(0)
  • 2021-01-31 05:17

    I am working on centos 7.

    I just want to add insecure-registry in docker config file then I changed "DOCKER_OPTS=--insecure-registry=...." in /etc/sysconfig/docker while it did not work.

    While I saw a INSECURE_REGISTRY in the config so I changed this variable and it WORKS!

    So I guess DOCKER_OPTS does not work here!

    But it worked on my unbuntu 14!

    It is really frustrating when using docker!

    0 讨论(0)
  • 2021-01-31 05:20

    I cannot believe how many answers there are for this. So here is another one for:

    • CentOS 7.3
    • Docker Version = 17.03.1-ce, API Version = 1.27

    This answer is built upon an unbelievable playing around combination of this answer and this one and this one.

    1. sudo vim /usr/lib/systemd/system/docker.service
    2. insert " -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock"
    3. sudo systemctl daemon-reload //refresh your file changes above
    4. sudo systemctl restart docker
    5. netstat -l | grep 4243 //verify port is open
    6. connect to your docker host from somewhere, like Jenkins Docker Plugin, i.e. tcp://[server_ip]:4243
    0 讨论(0)
  • 2021-01-31 05:21

    Based on https://docs.docker.com/engine/admin/configuring/

    sudo mkdir /etc/systemd/system/docker.service.d
    sudo vi /etc/systemd/system/docker.service.d/docker.conf

    [Service]
    ExecStart=
    ExecStart=/usr/bin/docker daemon -H fd:// -D -H tcp://127.0.0.1:4243
    

    sudo systemctl daemon-reload
    sudo systemctl restart docker

    0 讨论(0)
  • 2021-01-31 05:24

    1、edit /usr/lib/systemd/system/docker.service to add two param in the service section:

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

    [Service]

    ExecStart=

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

    2、reload the configuration,and then restart docker。

    # systemctl daemon-reload
    # systemctl restart docker
    

    3、to check for success, see if the return the following response。

    # ps -ef|grep docker
    

    root 26208 1 0 23:51 ? 00:00:00 /usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

    reference from Expose the Docker Remote API on Centos 7?

    0 讨论(0)
  • 2021-01-31 05:25

    It worked for me when I followed how its shown in the posts above with drop-in replacement files in: /etc/systemd/system/docker.service.d

    0 讨论(0)
提交回复
热议问题