1、docker容器启动时挂载docker.sock

docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock centos:7.6.1810

2、curl调用接口

curl -s --unix-socket /var/run/docker.sock http://localhost/containers/json

二、docker service实现

1、docker service启动时挂载

docker service create -p 8080 --name=tomcat --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock,readonly tomcat:8.5.41

2、进入对应容器curl调用接口

curl -s --unix-socket /var/run/docker.sock http://localhost/services

扩展:

在java程序中可以使用《java执行系统命令, 返回执行结果》一文中的工具类获取接口返回

参考连接:

https://portainer.readthedocs.io/en/latest/deployment.html

https://www.cnblogs.com/fundebug/p/6723464.html

 

相关文章:

  • 2021-11-05
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-07
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2020-06-25
  • 2022-12-23
  • 2021-07-15
相关资源
相似解决方案