配置启动参数
vim /usr/lib/systemd/system/docker.service
添加-H tcp://0.0.0.0:2375
[Service]
Type=notify
# 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 tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
systemctl daemon-reload
docker api 调用
curl http://localhost:2375/info | python -m json.tool
列举docker容器
curl http://localhost:2375/containers/json | python -m json.tool
列举docker镜像
curl http://localhost:2375/images/json | python -m json.tool
查询镜像详细信息
curl http://localhost:2375/images/pid/json | python -m json.tool
启动容器
curl -X POST -H "Content-Type: application/json" http://localhost:2375/containers/pid/start
停止容器
curl -X POST -H "Content-Type: application/json" http://localhost:2375/containers/pid/stop