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
compose run --name: distinction between service name and container name wrt project name #5147
Comments
To rephrase, what I'm trying to do is to use The --name option doesn't seem to respect the isolated environment option. |
Looking up here: Lines 1140 to 1156 in c8daf17
It looks like the service being run isn't affected by project-name at all. Only its dependencies are affected. I.e. Actually, for my use case (CI environment) I don't need interaction. I only need an ability to wait for a container to go down. So while |
This works as intended. |
@shin- It looks like you have ignored most of my messages. It's not the question issue. It's a feature request. |
You shouldn't use container names in this fashion. The recommended approach to this would be to use network aliases. |
Found similar issue: #4052 |
Tried your suggestion. Didn't work:
|
In your example,there's no guarantee version: '2'
networks:
internal:
services:
slave:
command: "sleep 999"
image: busybox
networks:
internal:
aliases:
- slave1
master:
command: sh -c "sleep 1; ping slave1"
depends_on:
- slave
image: busybox
networks:
internal:
aliases:
- master1
|
Looks to be working. Thanks! |
E.g.:
|
It's behavior carried over from before custom networks were a thing in Docker. I'm sure there's cases where it's still useful, but in your case it's obviously a problem since you can't have 2 containers with the same name. |
Ah, a legacy feature.
|
Use case
Run parallel
docker compose run
commands with an ability for dependent services to discover the "runned" service by its name.E.g. when I do this:
I expect 2 sets of all containers (2 networks) to be created, each having a discoverable service name "my_service_interactive".
But instead I get
the name "my_service_interactive" is already in use
.Problem
It looks like the --name directive sets both the container name and (internally linked) service name.
What I would want is an option to generate a unique container name, but provide a predefined service name.
It's not clear what is a use case of the
--name
option: to prevent docker from creating 2 run instances or to provide a predefined discoverable service name. Or both?The text was updated successfully, but these errors were encountered: