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

[BUG] Since 2.32.1 volumes_from is ignored when extends in used in the same service. #12419

Open
calebgcooper opened this issue Dec 21, 2024 · 0 comments

Comments

@calebgcooper
Copy link

calebgcooper commented Dec 21, 2024

Description

volumes_from is ignored in a service defined locally in docker-compose.yml file when extends is used in the same service. Regardless of the contents of the file which extends the service.

This is only present in 2.32.1 and is not present in 2.31.0.

I don't think that was the intended implementation of:
compose-spec/compose-go#718

As per manual:

volumes_from and depends_on are never shared between services using extends. These exceptions exist to avoid implicit dependencies; you always define volumes_from locally. This ensures dependencies between services are clearly visible when reading the current file. Defining these locally also ensures that changes to the referenced file don't break anything.

As I read it, it should be possible to use volumes_from as long as it is not in the file which extends the service.

Steps To Reproduce

Issue is only in Docker compose v2.32.1. Not Present in Docker compose v2.31.0.

docker-compose.yml similar to:

[[email protected] Ϯ test]$ cat docker-compose.yml 
x-source-image: &source-image 'gitlab-registry.cwd.supportlabs.dell/mediawiki/min/source:1.43.0'

services:
  source:
    image: *source-image

  php:
    extends:
      file: extras.yml
      service: php
    image: php:8.3.14-fpm-alpine3.21
    container_name: php
    volumes_from:
      - source

  web-server:
    image: nginx:1.27.3-alpine3.20
    container_name: web
    volumes_from:
      - source


networks:
  net:
    external: true
[[email protected] Ϯ test]$ 

After doing docker compose up (v2.32.1) there are no volume mounts present on the 'php' service:

[[email protected] Ϯ test]$ docker inspect -f '{{json .Mounts }}' php | jq 
[]
[[email protected] Ϯ test]$ 

However the 'web' service does show the expected volumes:

[[email protected] Ϯ test]$ docker inspect -f '{{json .Mounts }}' web | jq 
[
  {
    "Type": "volume",
    "Name": "5a62f63c2f7e08d668066923e6b09992c597f273d024b00c4bc01ebe8d17fa18",
    "Source": "/var/lib/docker/volumes/5a62f63c2f7e08d668066923e6b09992c597f273d024b00c4bc01ebe8d17fa18/_data",
    "Destination": "/build-scripts",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  },
  {
    "Type": "volume",
    "Name": "023c0e1a6151065bea1ad999a4d463da9b35e41b2f89a0385c920d1f8efcdec8",
    "Source": "/var/lib/docker/volumes/023c0e1a6151065bea1ad999a4d463da9b35e41b2f89a0385c920d1f8efcdec8/_data",
    "Destination": "/tmp",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  },
  {
    "Type": "volume",
    "Name": "edf983a26f5063666ebd012cf41edd7d515ca81acec43ac44c3ffac665a3e64a",
    "Source": "/var/lib/docker/volumes/edf983a26f5063666ebd012cf41edd7d515ca81acec43ac44c3ffac665a3e64a/_data",
    "Destination": "/var/www/html",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  },
  {
    "Type": "volume",
    "Name": "60647d8d550dc9f1036b1a78c589e5cf8c572afb63bb3eff7cb61eeb60f2def6",
    "Source": "/var/lib/docker/volumes/60647d8d550dc9f1036b1a78c589e5cf8c572afb63bb3eff7cb61eeb60f2def6/_data",
    "Destination": "/wiki-shared/vars",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  }
]
[[email protected] Ϯ test]$ 

Testing with docker-compose up -d (v2.31.0) we see the volumes also on the 'php' service:

[[email protected] Ϯ test]$ docker inspect -f '{{json .Mounts }}' php | jq 
[
  {
    "Type": "volume",
    "Name": "023c0e1a6151065bea1ad999a4d463da9b35e41b2f89a0385c920d1f8efcdec8",
    "Source": "/var/lib/docker/volumes/023c0e1a6151065bea1ad999a4d463da9b35e41b2f89a0385c920d1f8efcdec8/_data",
    "Destination": "/tmp",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  },
  {
    "Type": "volume",
    "Name": "edf983a26f5063666ebd012cf41edd7d515ca81acec43ac44c3ffac665a3e64a",
    "Source": "/var/lib/docker/volumes/edf983a26f5063666ebd012cf41edd7d515ca81acec43ac44c3ffac665a3e64a/_data",
    "Destination": "/var/www/html",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  },
  {
    "Type": "volume",
    "Name": "60647d8d550dc9f1036b1a78c589e5cf8c572afb63bb3eff7cb61eeb60f2def6",
    "Source": "/var/lib/docker/volumes/60647d8d550dc9f1036b1a78c589e5cf8c572afb63bb3eff7cb61eeb60f2def6/_data",
    "Destination": "/wiki-shared/vars",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  },
  {
    "Type": "volume",
    "Name": "5a62f63c2f7e08d668066923e6b09992c597f273d024b00c4bc01ebe8d17fa18",
    "Source": "/var/lib/docker/volumes/5a62f63c2f7e08d668066923e6b09992c597f273d024b00c4bc01ebe8d17fa18/_data",
    "Destination": "/build-scripts",
    "Driver": "local",
    "Mode": "",
    "RW": true,
    "Propagation": ""
  }
]
[[email protected] Ϯ test]$ 

Compose Version

[[email protected] Ϯ test]$ docker compose version
Docker Compose version v2.32.1
[[email protected] Ϯ test]$ docker-compose version
Docker Compose version v2.31.0
[[email protected] Ϯ test]$

Docker Environment

[[email protected] Ϯ test]$ docker info
Client: Docker Engine - Community
 Version:    27.4.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.19.3
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.32.1
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 70
  Running: 66
  Paused: 0
  Stopped: 4
 Images: 32
 Server Version: 27.4.1
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Using metacopy: false
  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 splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 88bf19b2105c8b17560993bee28a01ddc2f97182
 runc version: v1.2.2-0-g7cb3632
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 5.14.0-427.35.1.el9_4.x86_64
 Operating System: Rocky Linux 9.5 (Blue Onyx)
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.09GiB
 Name: apps1-cwd.devops.supportlabs.dell
 ID: a3889f80-73ea-4e51-a48d-f69b8cc07881
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

[[email protected] Ϯ test]$

Anything else?

No response

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

1 participant