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

Networks created in docker-compose file are not labeled with com.docker.compose.project #6636

Closed
bsideup opened this issue Apr 8, 2019 · 7 comments

Comments

@bsideup
Copy link

bsideup commented Apr 8, 2019

Description of the issue

Usually, every resource created by Docker Compose contains com.docker.compose.project label. But when compose creates a network, it is not labeled.

Context information (for bug reports)

Testcontainers' users report a lot of unused, prunnable networks:
testcontainers/testcontainers-java#955

Steps to reproduce the issue

  1. Create a Docker Compose file with a network
  2. Start it
  3. Inspect the created network, see "Labels": {}

Observed result

Networks are not labeled

Expected result

Networks (as well as any other Docker resource created by Docker Compose) should have a consistent com.docker.compose.project label set

@chris-crone
Copy link
Member

Hi @bsideup

Thanks for the report. Can you please provide:

  • An example Compose file that we can use to reproduce the issue
  • Which version of docker-compose that you have seen this with

@bsideup
Copy link
Author

bsideup commented Apr 9, 2019

@chris-crone
Copy link
Member

Thanks for the follow up.

I've confirmed that networks aren't labelled with that example. This appears to be a v2 issue as changing to v3, I see that the network is labelled.

Using:

version: '3'
services:
  redis:
    image: redis
    networks:
      - redis-net

networks:
  redis-net:

I see:

$ docker network inspect 6636_redis-net                                                                                                                                                                                                                                                                                                                                                                                 [13:43:33] 
[
    {
        "Name": "6636_redis-net",
        "Id": "1ff9571066bba2d522cc8e7485f496660d6d9528096180b1c8f56996514a7aa8",
        "Created": "2019-04-11T11:43:22.8889743Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.31.0.0/16",
                    "Gateway": "172.31.0.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "9eaf0011c9b783085e294617283245a91c570afa765ef45590a33be65775351c": {
                "Name": "6636_redis_1",
                "EndpointID": "a30b9404a0e9f5e8d7dd8646fc93c10409e9eb9647813700335eac20741494bf",
                "MacAddress": "02:42:ac:1f:00:02",
                "IPv4Address": "172.31.0.2/16",
                "IPv6Address": ""
            }
        },
        "Options": {},
        "Labels": {
            "com.docker.compose.network": "redis-net",
            "com.docker.compose.project": "6636",
            "com.docker.compose.version": "1.23.2"
        }
    }
]

@bsideup
Copy link
Author

bsideup commented Apr 11, 2019

Hi @chris-crone,

Thanks for trying, I did not know that it can be version specific!
Can we expect it to be eventually fixed in v2 or we need to find a workaround on our side?

@shin-
Copy link

shin- commented Apr 11, 2019

Hey @chris-crone @bsideup -- The reason for this is the v2.0 file format is mapped to an API version that didn't support labels on networks and volumes (see the code here). Using 2.1 or above will solve this issue.

@chris-crone
Copy link
Member

Thanks for the context @shin-!

@bsideup can you please try with a more recent version of the v2 file format and let me know if that fixes your issue. Note that if you specify version: '2' in your Compose file, it is actually version 2.0. If it fixes your issue, please close this issue.

@ulyssessouza
Copy link
Collaborator

Closing by inactivity. Looks like changing the version fixes the issue.
Please ask for re-opening if it's not the case

rnorth pushed a commit to testcontainers/testcontainers-java that referenced this issue Sep 9, 2019
…ge pull

Together with using Compose file 2.1 syntax, this is a solution to network cleanup issue described in:
 * #1767
 * #739
 * testcontainers/moby-ryuk#2
 * docker/compose#6636

Solution to general credential helper authenticated pull issues in:
 * docker/compose#5854

Tangentially should add support for v3 syntax (not yet tested) re #531
rnorth added a commit to testcontainers/testcontainers-java that referenced this issue Nov 23, 2019
* Upgrade docker-compose image to latest version and perform direct image pull

Together with using Compose file 2.1 syntax, this is a solution to network cleanup issue described in:
 * #1767
 * #739
 * testcontainers/moby-ryuk#2
 * docker/compose#6636

Solution to general credential helper authenticated pull issues in:
 * docker/compose#5854

Tangentially should add support for v3 syntax (not yet tested) re #531
@bsideup bsideup changed the title Labels created in docker-compose file are not labeled with com.docker.compose.project Networks created in docker-compose file are not labeled with com.docker.compose.project Nov 18, 2020
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

4 participants