Skip to content

[BUG] docker compose publish ignores required: false on env_file #13648

@karnarokEpoch

Description

@karnarokEpoch

Description

env_file with required: false is honoured at runtime (up, run, etc.)
but docker compose publish scans every env_file entry unconditionally,
failing if the file is absent:

env_file:
  - path: ./.env
    required: false
failed to scan env file ./.env: open ./.env: no such file or directory

Steps To Reproduce

  1. Create the file:
cat > compose.yaml <<EOF
services:
  whoami:
    image: docker.io/traefik/whoami:v1.11
    env_file:
      - path: ./.env
        required: false
EOF
  1. Publish (no .env present):
docker compose publish <registry>/<image>:<tag>

Compose Version

$ docker-compose version
Command 'docker-compose' not found, but can be installed with:
sudo snap install docker          # version 28.4.0, or
sudo apt  install docker-compose  # version 1.29.2-6
See 'snap info docker' for additional versions.

$ docker compose version
Docker Compose version v5.1.0

Docker Environment

$ docker info
Client: Docker Engine - Community
 Version:    29.3.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.31.1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.1.0
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 119
 Server Version: 4.9.3
 Storage Driver: overlay
  Supports d_type: true
  Native Overlay Diff: true
  Using metacopy: false
  Supports shifting: false
  Supports volatile: true
  Backing Filesystem: extfs
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge macvlan ipvlan
  Log: k8s-file none passthrough journald
 Swarm: inactive
 Runtimes: crun ocijail runsc crun-wasm kata krun runc runj youki
 Default Runtime: crun
 Init Binary: 
 containerd version: 
 runc version: 
 init version: 
 Security Options:
  seccomp
   Profile: default
  rootless
 Kernel Version: 6.6.87.2-microsoft-standard-WSL2
 Operating System: ubuntu
 OSType: linux
 Architecture: amd64
 CPUs: 8
 Total Memory: 7.557GiB
 Name: DENEC1
 ID: 22893162-076d-4bf1-b265-666029302de0
 Docker Root Dir: /home/karna/.local/share/containers/storage
 Debug Mode: false
 Experimental: true
 Live Restore Enabled: false
 Product License: Apache-2.0

Anything else?

I'm using podman with docker-compose-plugin. Docker Engine is not installed.
Docker CLI use podman thanks to export DOCKER_HOST="unix://${XDG_RUNTIME_DIR}podman/podman.sock"
I don't think it change anything but for transparency.

I have used an AWS ECS for my test.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions