-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Unable to run service with network_mode "service:NAME" #9055
Comments
just tested with Docker Compose version v2.2.2
|
Looks like it works if you skip straight to running If you follow the steps to reproduce (documented in description) its:
|
Is there somewhere I can start looking to work on this issue? |
I have exactly the same issue, Docker Desktop for Mac (Engine: 20.10.12, Compose: v2.2.3). Did anyone sorted this? Thanks. |
just tried to add the custom network name and add one to both services in networks:
Please check over how it works on your side. |
For some reason, I don't see a +1 emoji here.. I have a user experiencing the same issue (replicated using the example initially provided in the issue) Docker Compose version v2.2.3 They're using Ubuntu under WSL2. I just had them revert to using the separately installed docker-compose CLI (1.29.2, build 5becea4) and that's working. @vrusua example is invalid because you can't specify networks and network_mode together in the same service. Switching to using networks isn't a viable workaround for us either, as that's a completely different method. We want to be able to use network_mode as a service so the services can be addressed using localhost to each other. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We also have this issue especially on Docker Desktop for macOS; colleagues with Docker Compose v1.* can work fine, Docker Compose v2.* fails with: |
Unchecking |
I just found the same issue with that test env version: "3"
services:
pod:
image: k8s.gcr.io/pause:3.8
cli:
image: busybox
depends_on: [nginx]
network_mode: service:pod
nginx:
image: nginx:alpine
network_mode: service:pod docker-compose V1.29 runs it ok
but V2 fails
|
This issue has been automatically marked as not stale anymore due to the recent activity. |
Hi @ndeloof - this has been an issue for almost a year - see #8766 - we've had this issue as well. I did some digging and I found out some additional info. Hope this helps. This fails on v2 if the network (EDIT: IS) already setup, so just doing a I've tested this to be an issue on all docker-compose version v2, including the latest 2.11.1. It works on the latest v1 (1.29.2) Test file:
|
Just a note, It has been working on v1 for many years, afaik. This is a blocker using v2. |
Here is v1 code: Lines 1480 to 1482 in 30fcb72
and here is v2 code: compose/pkg/compose/convergence.go Lines 129 to 140 in 7cf5940
At a glance they do the same - take the first container from array and use its ID to replace network_mode: service:x with network_mode: container:y , but important difference is that in v1 it is an array of containers belonging to service x in contrast to array of all containers belonging to the project in v2. If "correct" container is on top of the list, then v2 code works just fine, but fails otherwise.
I will submit a PR in a moment. |
compose/pkg/compose/convergence.go Line 118 in 7cf5940
also, replacement only take place if
|
But not here: Lines 85 to 89 in 7cf5940
|
oh right, nice catch |
Submitted #10036. It is probably not the cleanest solution, but it seems to work. |
Description
This ticket is a duplicate of #8766 given it was marked as "closed" but is not resolved.
Unable run to execute
compose run <service>
when a service is usingnetwork_mode: service:nginx
Steps to reproduce the issue:
This is a docker-compose.yml file which can replicate the issue.
Commands which replicate the issue.
Describe the results you received:
Describe the results you expected:
The service container to execute within the same network as the "nginx" service in this case.
This worked with Compose v1.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
docker compose version
:Output of
docker info
:Additional environment details:
N/A
The text was updated successfully, but these errors were encountered: