How do i expose the Docker Remote API on Centos 7?
The systemd unit installed by the Docker corp package hardcodes the command line used to start the docker daemon:
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
[...]
There is no support for reading a file from /etc/sysconfig
or elsewhere to modify the command line. Fortunately, systemd gives us the tools we need to change this behavior.
The simplest solution is probably to create the file /etc/systemd/system/docker.service.d/docker-external.conf
(the exact filename doesn't matter; it just needs to end with .conf
) with the following contents:
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
And then:
systemctl daemon-reload
systemctl restart docker
This is actually documented on the Docker website in this document, which includes instructions for a more flexible solution that will allow you to use files in /etc/sysconfig
to control the daemon.
user3412172
Updated on August 28, 2022Comments
-
user3412172 over 1 year
On ubuntu i can go into
/etc/init/docker.conf
and put inDOCKER_OPTS='-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock'
to get the json data to display on my browser but how can i do it for Centos?I have tried creating a file in
/etc/sysconfig/docker
and placingother_args="-H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock"
inside the file and restarting docker but it doesn't do anything.