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 config returns "undefined network default" error when service uses default network and --compatibility is applied #9015

Closed
eliottwiener opened this issue Dec 8, 2021 · 11 comments
Labels

Comments

@eliottwiener
Copy link

eliottwiener commented Dec 8, 2021

Description

When a service uses the default network, calling docker compose --compatibility config returns an error like:

service ... refers to undefined network default: invalid compose project

Steps to reproduce the issue:

  1. Create a compose file called example.yml that contains the following:
services:
  helloworld:
    image: helloworld
    networks:
      default:
  1. Run docker compose --compatibility --file example.yml --project-name myproject config

Describe the results you received:

An error is emitted:

service "helloworld" refers to undefined network default: invalid compose project

Describe the results you expected:

compose should output the effective configuration:

services:
  helloworld:
    image: helloworld
    networks:
      default: null
networks:
  default:
    name: myproject_default

Additional information you deem important (e.g. issue happens only occasionally):

This works as expected in v2.1.1 . I was able to determine via git bisect that this regression was introduced with d00eacb, from #8943.

Additionally, it should be noted that compose-switch passes --compatibility as of docker/compose-switch#21 (included in v1.0.3).

Output of docker compose version:

Docker Compose version v2.2.2

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Docker Buildx (Docker Inc., v0.7.0-10-gab73275f.m)
  compose: Docker Compose (Docker Inc., v2.2.2)
  scan: Docker Scan (Docker Inc., v0.9.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 1
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.0-9-amd64
 Operating System: Debian GNU/Linux 11 (bullseye)
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 15.55GiB
 Name: ...
 ID: RFDS:PPSP:TOKV:SUYH:M5CB:QGBG:63EO:4HYM:5BX4:FYHX:OFSM:LK44
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: eliottwiener
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details:

@cdavernas
Copy link

Facing the exact same issue here, with following docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.7.1)
  compose: Docker Compose (Docker Inc., v2.2.1)
  scan: Docker Scan (Docker Inc., 0.9.0)

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 13
 Server Version: 20.10.11
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version: v1.0.2-0-g52b36a2
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.4.72-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 7.689GiB
 Name: docker-desktop
 ID: 3R7B:QKPR:V4KB:JG3I:WA2N:NGG4:XLNK:DS46:XXFB:CRIR:YI72:M7JF
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support

@ndeloof
Copy link
Contributor

ndeloof commented Dec 10, 2021

right, as we skip normalization, we don't declare the implicit default network anymore.
question: why do you explicitly assign your services to networks: default, as .. you don't need to!

@cdavernas
Copy link

cdavernas commented Dec 13, 2021

@ndeloof Well, as far as I know, you do need to specify default for services that are using multiple networks, so they are still able to communicate with other services residing on the default's. Am I missing something?

@ndeloof
Copy link
Contributor

ndeloof commented Dec 13, 2021

right, good point

@BlackthornYugen
Copy link

This issue hits me too. I need to specify default as well as other shared networks that are defined.

@mmrko
Copy link

mmrko commented Dec 15, 2021

Same here, we reference default for specifying aliases.

@pabloroman
Copy link

Same problem here. Has anyone found a workaround yet?

@eliottwiener
Copy link
Author

@pabloroman There are some workarounds to try, depending on how you are using compose and what your needs are:

  1. Downgrade to v2.1.1

  2. Include the default network explicitly in the networks section:

services:
  helloworld:
    image: helloworld
    networks:
      default: null
networks:
  default:
    name: myproject_default
  1. Omit the --compatibility option. If you are calling compose via compose-switch (e.g. if you are calling docker-compose instead of docker compose), then --compatibility may be applied. You may not need this option.

ollietreend added a commit to alphagov/govuk-docker that referenced this issue Jan 10, 2022
The Docker Compose project has moved from v1 to v2.

For now, it's still possible to opt-out of v2 and revert to v1 when using Docker for Mac. However this option will likely go away at some point. It's therefore a good idea to ensure GOV.UK Docker works with both versions.

As far as I can see, the only compatibility issue that existed is that the `nginx` container attaches to the 'default' network. As I understand it, the network called `default` is no longer implicitly created with Docker Compose v2, so it needs to be defined in the docker compose file.

For more info, see: docker/compose#9015

It's not clear when this change happened as it's not documented as a known change: https://docs.docker.com/compose/compose-file/compose-versioning/
ollietreend added a commit to alphagov/govuk-docker that referenced this issue Jan 10, 2022
The Docker Compose project has moved from v1 to v2.

For now, it's still possible to opt-out of v2 and revert to v1 when using Docker for Mac. However this option will likely go away at some point. It's therefore a good idea to ensure GOV.UK Docker works with both versions.

As far as I can see, the only compatibility issue that existed is that the `nginx` container attaches to the 'default' network. As I understand it, the network called `default` is no longer implicitly created with Docker Compose v2, so it needs to be defined in the docker compose file.

For more info, see: docker/compose#9015

It's not clear when this change happened as it's not documented as a known change: https://docs.docker.com/compose/compose-file/compose-versioning/
ollietreend added a commit to alphagov/govuk-docker that referenced this issue Jan 10, 2022
The Docker Compose project has moved from v1 to v2.

For now, it's still possible to opt-out of v2 and revert to v1 when using Docker for Mac. However this option will likely go away at some point. It's therefore a good idea to ensure GOV.UK Docker works with both versions.

As far as I can see, the only compatibility issue that existed is that the `nginx` container attaches to the 'default' network. As I understand it, the network called `default` is no longer implicitly created with Docker Compose v2, so it needs to be defined in the docker compose file.

For more info, see: docker/compose#9015

It's not clear when this change happened as it's not documented as a known change: https://docs.docker.com/compose/compose-file/compose-versioning/
@stale
Copy link

stale bot commented Jul 10, 2022

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.

@stale stale bot added the stale label Jul 10, 2022
@stale
Copy link

stale bot commented Jul 31, 2022

This issue has been automatically closed because it had not recent activity during the stale period.

1 similar comment
@stale
Copy link

stale bot commented Aug 13, 2022

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants