Configure Docker api to accept remote calls

Asked

Viewed 76 times

0

I’m trying to set up the Docker api to accept remote calls.

I modified the file /etc/sysconfig/docker as follows :

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--selinux-enabled --log-driver=journald --signature-verification=false'
DOCKER_OPTS='-H tcp://0.0.0.0:4242 -H unix:///var/run/docker.sock'


if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.

# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp

# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false

# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
DOCKERBINARY=/usr/bin/docker-latest
DOCKERDBINARY=/usr/bin/dockerd-latest
DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest
DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest

After setting, when performing

systemctl restart docker.service

I have the following exit :

Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

When executing systemctl status docker.service -l :

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           └─override.conf, startup_options.conf
   Active: failed (Result: exit-code) since Thu 2019-04-25 16:11:51 EDT; 1min 2s ago
     Docs: http://docs.docker.com
  Process: 7080 ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 (code=exited, status=1/FAILURE)
 Main PID: 7080 (code=exited, status=1/FAILURE)

Apr 25 16:11:50 docker.example.com systemd[1]: Starting Docker Application Container Engine...
Apr 25 16:11:51 docker.example.com dockerd[7080]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [fd:// tcp://0.0.0.0:2376], from file: [fd:// tcp://0.0.0.0:2376])
Apr 25 16:11:51 docker.example.com systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Apr 25 16:11:51 docker.example.com systemd[1]: Failed to start Docker Application Container Engine.
Apr 25 16:11:51 docker.example.com systemd[1]: Unit docker.service entered failed state.
Apr 25 16:11:51 docker.example.com systemd[1]: docker.service failed.

when executing journalctl -xe

    Apr 25 16:05:09 docker.example.com systemd[1]: Starting Docker Application Container Engine...
-- Subject: Unit docker.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has begun starting up.
Apr 25 16:05:09 docker.example.com dockerd[6995]: unable to configure the Docker daemon with file /etc/docker/daemon.json: the fo
Apr 25 16:05:09 docker.example.com systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Apr 25 16:05:09 docker.example.com systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Apr 25 16:05:09 docker.example.com systemd[1]: Unit docker.service entered failed state.
Apr 25 16:05:09 docker.example.com systemd[1]: docker.service failed.
Apr 25 16:05:09 docker.example.com polkitd[641]: Unregistered Authentication Agent for unix-process:6938:818820 (system bus name
Apr 25 16:06:55 docker.example.com dbus-daemon[645]: dbus[645]: [system] Activating via systemd: service name='org.freedesktop.ho
Apr 25 16:06:55 docker.example.com dbus[645]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbu
Apr 25 16:06:55 docker.example.com systemd[1]: Starting Hostname Service...
-- Subject: Unit systemd-hostnamed.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-hostnamed.service has begun starting up.
Apr 25 16:06:55 docker.example.com dbus[645]: [system] Successfully activated service 'org.freedesktop.hostname1'
Apr 25 16:06:55 docker.example.com dbus-daemon[645]: dbus[645]: [system] Successfully activated service 'org.freedesktop.hostname
Apr 25 16:06:55 docker.example.com systemd[1]: Started Hostname Service.
-- Subject: Unit systemd-hostnamed.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-hostnamed.service has finished starting up.
--
-- The start-up result is done.

I’m wearing RHEL 7.1

1 answer

0

  • I need to modify some Docker parameter to enable using the ? api I can specify a port for the api ?

  • 1- You do not need to modify anything.

  • 2 - You access the Docker program even through the SDK already in it. example if you do this in Python you can use this lib https://pypi.org/project/docker/, but there are similar for each language

  • If you want an API ready to consume, you can use Cadvisor, a Google project that monitors containers and provides an API interface to consume https://github.com/google/cadvisor

Browser other questions tagged

You are not signed in. Login or sign up in order to post.