Centos Docker1.12 configuration method for remote Rest api access

  • 2020-06-01 11:27:10
  • OfStack

By default, Docker does not have HTTP remote access enabled. By default, docker daemon is only supported through unix socket communication, and the configuration needs to be modified to use HTTP restful interface.

1, modify the configuration file, the file location/lib/systemd/system/docker service. Change the original ExecStart to:

Description=Docker Application Container Engine
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
#ExecStart=/usr/bin/dockerd -H
ExecStart=/usr/bin/docker daemon --tls=false -H unix:///var/run/docker.sock -H tcp://
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
# set delegate yes so that systemd does not reset the cgroups of docker containers
# kill only the docker process, not all processes in the cgroup

2. Perform

systemctl daemon-reload
systemctl restart docker.service

Note: if the docker command is not available, configure it in etc/profile:

export DOCKER_HOST= ''

Is the effect of

source /etc/profile

3. Official API documentation

Official link: Docker Remote API v1.24

Related articles: