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

查看:2620
本文介绍了从正在运行的容器获取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 也未提供获取与撰写相关的信息的方法

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.

我要在脚本中执行的操作:

What I'd like to do in a script:


  • 列出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< certain_container>

  • 使用找到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天全站免登陆