why do docker compose up --scale set instance to 0 - docker

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

Related

docker-compose fails to run on remote host from local

Via my local I would like to run docker-compose on my remote machine. I have found two ways that should accomplish this but am running into errors.
Fist I am running the following versions:
me:api$ docker-compose -v
docker-compose version 1.29.2, build unknown
me:api$ docker -v
Docker version 20.10.7, build 20.10.7-0ubuntu5~20.04.2
First way and the way I would prefer for this to work is to the the --context flag. Based on this blog post should be possible.
I created the context like so:
docker context create prod --docker "host=ssh://user#host.com"
I can then run the following and get an output of running containers
docker --context prod ps
However running with docker-compose the command fails
docker-compose --context prod -f docker-compose.yml -f docker-compose.prod.yml up -d
ERROR: Context 'prod' not found
The other option was to use the -H flag based on this SO answer to set the host that I want to execute the commands on. Yes I can SSH into my machine with the user I am using.
docker-compose -H ssh://user#host -f docker-compose.yml -f docker-compose.prod.yml up -d
/bin/sh: 1: ssh: Permission denied
Well it does not look great. I have not been able to get any of the methods to work with docker-compose however there is a new (at the time of writing this) docker compose replacement from docker. The instructions are here. I was hoping that the --context flag would work but it is not found with the new version which leads me to believe that it did not work before. The -H flag lead to the same Permission Denied error as before.
The only way I was able to get this to work was by setting the DOCKER_HOST environment variable.

Docker-compose not show logs

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

Containers start with docker-compose up, are listed with docker ps, then don't appear with docker-compose

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

Can't find docker-compose running

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

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.
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

Resources