I'm trying to stop a container generated by a docker-compose up but I can't find where this docker-compose was started. If I try to kill the docker container it is automatically recreated (as expected since it is docker-compose).
When running the command docker-compose ps in the folder containing the docker-compose.yml file I get an empty result, so it should be somewhere else...
How can I find where the docker compose is running and finally stop it?
Use docker ps -a | grep <certain_container>
Use locate docker-compose.yml and find the one that you want
Use docker-compose down
Option #1:
Install docker-compose which would be available on your path using the official instructions - https://docs.docker.com/compose/install/.
You can then go to the folder containing the docker-compose.yml and run docker-compose down.
Option #2:
Search for the file using something like:
find / -name "docker-compose"
You can then use the absolute path when running the command.
Option #3:
Update your containers restart policy:
docker update --restart=no container_name
Related
I am using a public docker compose plugin to run docker compose job on service machine.
I see this line of code
docker-compose -f docker-compose.yml -p buildkite18e15a6103824eb89c747d49151c7eea up --scale build-premade=0 build-premade
What is the purpose of running --scale build-premade=0? I get an error when I try to run this locally. (docker-compose up doc grep for --scale)
no container found for project "{project_name}": not found.
Anyone seen this before or knows how to get around this? I am guessing there is a docker setting or config somewhere?
reference to GH Issue - https://github.com/buildkite-plugins/docker-compose-buildkite-plugin/issues/322
I'm runing my api of express and mongo with docker-compose using the command docker-compose up, all fine but when i try show the logs have the next output error:
With docker-compose logs you need to use the name of the service in the docker-compose.yaml not the name of the container.
You ran docker-compose logs -f backend_api_1, which is the name of the container. If your docker-compose file does not contain any special renaming, the following should work: docker-compose logs -f backend_api (assuming the service is called backend_api)
This is a common confusion point with docker-compose orchestration. Docker compose deals with services, which then can start one or more containers for a service.
You can clarify this for yourself by looking at the manual page for whatever command you plan to use, as it will tell you whether it requires a service name or a container name.
For docker-compose logs the manual shows:
Usage: logs [options] [SERVICE...]
Since we don't have your docker-compose.yaml to refer to, we can only infer that you may have named the service backend_api. I'm just repeating the answer provided by Dennis van de Hoef, which is a reasonable guess based on how docker will name containers for you.
docker-compose logs -f backend_api
The docker logs command can be used to look at the logs of a container.
docker logs -f backend_api_1
I've got an issue on ubuntu 18.04 where occasionally running docker-compose up results in the containers starting, the networking between them behaving as expected yet according to docker-compose they aren't there.
docker ps shows the containers exist.
UPDATE: after some comments:
docker-compose ps shows nothing. Also, the problem is intermittent meaning any example is hard to come by unfortunately.
Do you see them in docker ps -a ? You should add docker-compose -d up for detached mode.
Try running
docker-compose ps
from where your .yml file is located. It will show you the list of all docker containers generated from that .yml file
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.
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
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
I am trying to run docker-compose ps and docker-compose logs and neither are showing any output. I was able to run docker-compose up and verified the correct containers are started with docker ps. However docker-compose logs and ps dont show anything
> sudo docker-compose -f /opt/docker-compose/server1-compose.yml ps
Name Command State Ports
------------------------------
> sudo docker-compose -f /opt/docker-compose/server1-compose.yml logs
Attaching to
Both commands are returning intended output. What is wrong here?
docker-compose version: 1.4.2
Docker version 1.7.1, build 786b29d
thanks so #dnephin to posting a response. For completeness here it is:
dnephin-
" I suspect what's happening here is that the project name is
different. The default project name is the basename of a directory, so
if you run docker-compose from a different directory you might get a
different project name.
You can set it with either -p or COMPOSE_PROJECT_NAME environment
variable. If you look at the first part of the container names (before
the first underscore) that's the project name.
There are open issues to configure the project name from a file. I
think we'll be looking to implement that soon."
Adding the -p switch to my compose command fixed the issue.
ie: sudo docker-compose -f /opt/docker-compose/server1-compose.yml logs -p projectname