Maksim Luzik
Maksim Luzik

Reputation: 6733

How to know which command or compose file has been used to start Docker containers?

Is there any way to find a source of the docker container script? I have a setup where I can not find any docker-compose.yml file nor the bash script etc that would have run all the Docker containers currently running. I have a virtual machine that starts docker containers on the startup, but have no idea which file is actually run.

Upvotes: 4

Views: 2595

Answers (3)

Tom
Tom

Reputation: 7992

This information is available from docker inspect:

$ docker inspect my_container | jq '.[]Config.Labels."com.docker.compose.project.config_files"'

This will spit out the path to the compose file used to start the stack.

Upvotes: 0

Muh faris
Muh faris

Reputation: 196

i think no option to know which docker-compose file is use. but you can check manual every you project folder.

the docker-compose mechanism is by matching the docker-compose.yml file. so if you run command sudo docker-compose ps in every your project folder. docker-compose will match between the docker-compose file used by container and docker-compose file in your project, if the same than the results will be displayed, if not the results is not displayed

Upvotes: 3

Tarun Lalwani
Tarun Lalwani

Reputation: 146630

If the containers are running automatically on reboot and you have no cron/bash profile/rc.local or any other startup screen then that may mean that they are containers with --restart option set. You can change that by running below command

docker ps -q | xargs docker update --restart no
docker ps -q | xargs docker stop

Then restart the machine. The containers should not start. If they do then you have some script somewhere which is starting them

Upvotes: 2

Related Questions