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] docker compose config does not provide validation logic for complete project when individual compose file has profiles mentioned it #12499

Closed
shantanoo-desai opened this issue Jan 25, 2025 · 1 comment

Comments

@shantanoo-desai
Copy link
Contributor

shantanoo-desai commented Jan 25, 2025

Description

validation of a compose file(s) provides invalid output when performing docker compose config on the complete project as well as on individual files. This bug makes it not possible whether the docker compose files / project is actually valid or not.

Steps To Reproduce

Following is the test structure:

bug-dc-profiles
.
├── compose.yml
├── docker-compose.test1.yml
└── docker-compose.test.yml

Contents with profiles specified

profile names are only for testing purpose and bear no real utility in this example

docker-compose.test.yml

services:
  test_cntr:
    image: alpine:latest
    command: "echo test"
    profiles: 
      - test-prof

docker-compose.test1.yml

services:
  test-cntr-2:
    image: ubuntu:latest
    command: "echo test1"
    profiles:
      - test-debug-prof

compose.yml (entrypoint file)

include:
  - path: ./docker-compose.test.yml
  - path: ./docker-compose.test1.yml

Testing with profiles

> docker compose config
name: bug-dc-profiles
services: {}

testing it with individual files:

> docker compose -f docker-compose.test.yml config
name: bug-dc-profiles
services: {}

> docker compose -f docker-compose.test1.yml config
name: bug-dc-profiles
services: {}

Content without profiles

removing profiles from either one of the file provides a configuration validation but with only the contents of the file where those profiles were removed.

docker-compose.test1.yml

services:
  test-cntr-2:
    image: ubuntu:latest
    command: "echo test1"

docker-compose.test.yml remains the same as before

Testing without profiles

> docker compose config
name: bug-dc-profiles
services:
  test-cntr-2:
    command:
      - echo
      - test1
    image: ubuntu:latest
    networks:
      default: null
networks:
  default:
    name: bug-dc-profiles_default

as seen here only the test-cntr-2 is validated.

removing profiles from all the files gives the accurate output:

> docker compose config # removed all profiles from files
name: bug-dc-profiles
services:
  test-cntr-2:
    command:
      - echo
      - test1
    image: ubuntu:latest
    networks:
      default: null
  test_cntr:
    command:
      - echo
      - test
    image: alpine:latest
    networks:
      default: null
networks:
  default:
    name: bug-dc-profiles_default

Compose Version

v2.31.0

Docker Environment

Client:
 Version:    27.3.1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.19.2
    Path:     /usr/lib/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.31.0
    Path:     /usr/lib/docker/cli-plugins/docker-compose

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 42
 Server Version: 27.3.1
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: true
  Native Overlay Diff: false
  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: 207ad711eabd375a01713109a8a197d197ff6542.m
 runc version: 
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.6.65-1-MANJARO
 Operating System: Manjaro Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 30.58GiB
 Name: shan-pc
 ID: DEGH:RPQ4:ONO5:K27S:6T47:BDMJ:Y5RX:RQ3J:3D2R:VIUN:STZ6:WTOQ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

Anything else?

  • docker compose config --profiles lists out the profiles, but docker compose config --services does not provide anything.

  • Only when the profiles are removed does docker compose config --services lists the values of the services.

  • only was to resolve this solution is docker compose --profile test-debug-prof config provides the configuration of the specific file.

@shantanoo-desai shantanoo-desai changed the title [BUG] docker compose config does not provide validation logic when individual compose file has profiles mentioned it [BUG] docker compose config does not provide validation logic for complete project when individual compose file has profiles mentioned it Jan 25, 2025
@ndeloof
Copy link
Contributor

ndeloof commented Jan 27, 2025

config command goal is not to provide validation of a whole compose file, but to compute and show the actual model that will be used by other compose commands. Disabled profiles then are excluded, as one could expect.
You can for all profiles to be enabled by running docker compose --profile="*" config

@ndeloof ndeloof closed this as completed Jan 27, 2025
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

2 participants