Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker-compose run ignores the container_name directive #12295

Open
eldarj opened this issue Nov 14, 2024 · 1 comment
Open

docker-compose run ignores the container_name directive #12295

eldarj opened this issue Nov 14, 2024 · 1 comment

Comments

@eldarj
Copy link

eldarj commented Nov 14, 2024

Description

See #1753 reported by @dunk and @aanand 's PR #1755 for more details.

In the #1753 issue reported, @dunk executed:

docker-compose up
docker-compose run myservice
PR #1930 adds a --name param to docker-compose allowing for one off executions with a custom name

Since a container with a fixed name is already running, the behavior of docker-compose run should be no different than that of docker-compose scale, which is basically the same thing as running docker run --name $some_name_that_already_exists.

Now, when running docker-compose up, the container_name directive is respected; when running docker-compose run myservice, the container_name directive is ignored and the default auto-generated container name is used.

Steps To Reproduce

No response

Compose Version

$ docker-compose --version
docker-compose version: 1.4.0
@ndeloof
Copy link
Contributor

ndeloof commented Nov 14, 2024

You're using docker compose v1 which is End of Life for years. Urgently adopt Docker Compose v2 !

docker-compose run is by design used to run one-off command, expected to complete short time. Typically, running some data migration or maintenance tasks using same image as the main service. Such a container name MUST NOT collide with service name, which in many cases is running concurrently. So the generated name with a random suffix.

Can you please clarify the use-case you have to require a fixed container name ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants