从正在运行的容器中获取 docker-compose.yml 文件位置? [英] Get docker-compose.yml file location from running container?

查看:138
本文介绍了从正在运行的容器中获取 docker-compose.yml 文件位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过执行 docker-compose up 创建了一些正在运行的 docker 容器.

I have a few running docker containers created by executing docker-compose up.

有没有什么办法可以通过检查正在运行的容器来获取用于启动这些容器的相应 docker-compose.yml 文件的确切文件路径?

Is there any way to get the exact file path of the corresponding docker-compose.yml file used to start these containers, just by inspecting the running containers?

据我所知,docker inspect CONTAINER_NAME 没有提供这些信息,docker-compose 也没有提供从运行中获取 compose 相关信息的方法.容器.

As far as I can see, docker inspect CONTAINER_NAME does not provide this information, nor does docker-compose provide a method to get compose-related information from a running container.

我想在脚本中做什么:

  • 列出 docker 主机上某些正在运行的容器
  • 获取相应的docker-compose.yml文件位置
  • 使用docker-compose一次性重启对应docker-compose项目的所有容器
  • list certain running containers on a docker host
  • get the corresponding docker-compose.yml file locations
  • use docker-compose to restart all containers of the corresponding docker-compose projects at once

推荐答案

目前不可能.

作为替代,可能会发现以下有用:

As an alternative might find the following helpful:

  • 使用docker ps -a |grep
  • 使用定位docker-compose.yml并找到你想要的
  • 使用docker-compose restart(执行docker-compose查看选项)
  • Use docker ps -a | grep <certain_container>
  • Use locate docker-compose.yml and find the one that you want
  • Use docker-compose restart (do docker-compose to see option)

这篇关于从正在运行的容器中获取 docker-compose.yml 文件位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆