配置docker API
  TEZNKK3IfmPf 2023年11月14日 24 0

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
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月14日 0

暂无评论

推荐阅读
  TEZNKK3IfmPf   2024年05月17日   27   0   0 API
  TEZNKK3IfmPf   2024年04月26日   54   0   0 Docker
TEZNKK3IfmPf