Docker の Remote API を有効
下記の参考元サイトをremote APIの有効手順を実施する
https://success.docker.com/article/How_do_I_enable_the_remote_API_for_dockerd
#使用Dockerバージョン:17.11.0-ce
1.docker起動ファイル作成
[root@sv01 ~]# cd /etc/systemd/system/
[root@sv01 system]# mkdir docker.service.d
[root@sv01 system]# cd docker.service.d/
[root@sv01 docker.service.d]# more startup_options.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2736
[root@sv01 docker.service.d]#
※実際に起動したファイルの内容は手順3を参照すること。
2.プロセスの再起動
[root@sv01 ~]# systemctl daemon-reload
[root@sv01 ~]# systemctl restart docker.service
★起動できない!
[root@sv01 docker.service.d]# systemctl daemon-reload
[root@sv01 docker.service.d]# systemctl restart docker.service
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@sv01 docker.service.d]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/docker.service.d
mqstartup_options.conf
Active: failed (Result: start-limit) since 金 2017-12-22 21:55:58 JST; 18s ago
Docs: https://docs.docker.com
Process: 1546 ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 (code=exited, status=1/FAILURE)
Main PID: 1546 (code=exited, status=1/FAILURE)
12月 22 21:55:58 sv01 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
12月 22 21:55:58 sv01 systemd[1]: Failed to start Docker Application Container Engine.
12月 22 21:55:58 sv01 systemd[1]: Unit docker.service entered failed state.
12月 22 21:55:58 sv01 systemd[1]: docker.service failed.
12月 22 21:55:58 sv01 systemd[1]: docker.service holdoff time over, scheduling restart.
12月 22 21:55:58 sv01 systemd[1]: start request repeated too quickly for docker.service
12月 22 21:55:58 sv01 systemd[1]: Failed to start Docker Application Container Engine.
12月 22 21:55:58 sv01 systemd[1]: Unit docker.service entered failed state.
12月 22 21:55:58 sv01 systemd[1]: docker.service failed.
3.設定修正
以下のサイトをもとに設定ファイルを修正
https://forums.docker.com/t/expose-the-docker-remote-api-on-centos-7/26022/2
[root@sv01 docker.service.d]# more startup_options.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
[root@sv01 docker.service.d]#
4.プロセスの再起動
今回は問題なくプロセスリスタートが出来た
[root@sv01 ~]# systemctl daemon-reload
[root@sv01 ~]# systemctl restart docker.service
5.起動確認
■プロセス
[root@sv01 docker.service.d]# ps -aux | grep docker
root 1600 0.9 1.4 446900 27884 ? Rsl 22:04 0:00 /usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
root 1603 0.1 0.4 276792 8736 ? Ssl 22:04 0:00 docker-containerd --config /var/run/docker/containerd/containerd.toml
root 1703 0.0 0.0 112676 980 pts/0 R+ 22:04 0:00 grep --color=auto docker
[root@sv01 docker.service.d]#
6.APIの簡易確認
一応、情報も取得できるので問題なさそう。
[root@sv01 ~]# curl -X GET http://127.0.0.1:2375/version
{"Version":"17.11.0-ce","ApiVersion":"1.34","MinAPIVersion":"1.12","GitCommit":"1caf76c","GoVersion":"go1.8.3","Os":"linux","Arch":"amd64","KernelVersion":"3.10.0-693.5.2.el7.x86_64","BuildTime":"2017-11-20T18:45:06.000000000+00:00"}
[root@sv01 ~]#
#---取得情報---#
"Version":"17.11.0-ce",
"ApiVersion":"1.34",
"MinAPIVersion":"1.12",
"GitCommit":"1caf76c",
"GoVersion":"go1.8.3",
"Os":"linux",
"Arch":"amd64",
"KernelVersion":"3.10.0-693.5.2.el7.x86_64",
"BuildTime":"2017-11-20T18:45:06.000000000+00:00"