Set Docker_Opts in centos

后端 未结 12 1914
我在风中等你
我在风中等你 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:44

    I believe things have changed now, this answer by Brian Ogden had worked for me earlier but didn't work on my environment today, probably with the updated versions of the docker, kernel, and OS.

    CentOS 7.4.1708 (on AWS)
    Docker 17.03.2-ce
    API 1.27
    

    This is what worked after few hit and trials. I could not find it documented anywhere.

    In file /etc/systemd/system/docker.service.d/execstart.conf, replace the last ExecStart (there are two) with below

    ExecStart=/usr/bin/dockerd --graph=/var/lib/docker --storage-driver=overlay -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
    

    Now, my files looks like this

    # cat /etc/systemd/system/docker.service.d/execstart.conf
    [Service]
    Restart=always
    StartLimitInterval=0
    RestartSec=15
    ExecStartPre=-/sbin/ip link del docker0
    ExecStart=
    ExecStart=/usr/bin/dockerd --graph=/var/lib/docker --storage-driver=overlay -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
    #
    

    Once, the above file is changed just the run the below command to activate the changes.

    # systemctl daemon-reload && systemctl stop docker && rm -f /var/run/docker.sock && systemctl start docker
    

    To verify if everything is working fine, you can run any (or all) of below commands

    # systemctl status docker.service | grep tcp
               ├─21812 /usr/bin/dockerd --graph=/var/lib/docker --storage-driver=overlay -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
    #
    # netstat -an | grep 4243
    tcp6       0      0 :::4243                 :::*                    LISTEN
    #
    # ps aux | grep [4]243
    root     21812  1.0  0.8 1017512 67876 ?       Ssl  15:11   0:06 /usr/bin/dockerd --graph=/var/lib/docker --storage-driver=overlay -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
    #
    # docker -H :4243 info
    

提交回复
热议问题