Skip to content

[BUG] Wrong path resolution for env files if service has been extended #10258

@alessandrograndi

Description

@alessandrograndi

Description

Docker compose tries to load the env_file from a wrong path when the service is extended from a compose file in another path.

This happens in version v2.16.0 and was not happening in version v2.15.1

Steps To Reproduce

  1. Create the following compose.yaml in the directory "my_submodule":

my_submodule/compose.yaml

services:
  my-app:
    image: my-image:latest
    env_file:
      - .docker/my_env_data.conf
  1. Create a compose.yaml in the base directory of your project:

compose.yaml

services:
  my-app:
    extends:
      file: my_submodule/compose.yaml
      service: my-app
  1. The env file will be loaded from the path $BASE_DIR/.docker/my_env_data.conf instead of $BASE_DIR/my_submodule/.docker/my_env_data.conf (like it was until v2.15.1)

Compose Version

Docker Compose version v2.16.0

Docker Environment

docker info
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.10.2)
  compose: Docker Compose (Docker Inc., v2.16.0)
Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 20.10.23
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 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.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 5b842e528e99d4d4c1686467debf2bd4b88ecd86
 runc version: v1.1.4-0-g5fd4c4d1
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 6.1.0-3-amd64
 Operating System: Alpine Linux v3.17
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 62.23GiB
 Name: ---
 ID: ---
 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
 Product License: Community Engine

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions