docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.01k stars 5.23k forks source link

[BUG] docker compose config --no-interpolate decoding error #12281

Closed oliora closed 2 days ago

oliora commented 2 days ago

Description

Running docker compose config option --no-interpolate is not compatible with printing information options like --services.

Running docker compose -f my_config.yaml config --services works fine but if I add --no-interpolate option e.g. docker compose -f my_config.yaml config --services --no-interpolate then the run fails with error:

decoding failed due to the following error(s):

'services[frontend].ports[0]' expected a map, got 'string'
'services[frontend].ports[1]' expected a map, got 'string'

Same error with using some other printing options e.g. --volumes.

I understand that without interpolation it may not be possible to print requested information but in such case there should be a more clear error message.

Steps To Reproduce

No response

Compose Version

Docker Compose version v2.29.2-desktop.2

Docker Environment

Client:
 Version:    27.2.0
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.16.2-desktop.1
    Path:     /Users/oliora/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.29.2-desktop.2
    Path:     /Users/oliora/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.34
    Path:     /Users/oliora/.docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Alpha) (Docker Inc.)
    Version:  v0.0.15
    Path:     /Users/oliora/.docker/cli-plugins/docker-desktop
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     /Users/oliora/.docker/cli-plugins/docker-dev
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.25
    Path:     /Users/oliora/.docker/cli-plugins/docker-extension
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.5
    Path:     /Users/oliora/.docker/cli-plugins/docker-feedback
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.3.0
    Path:     /Users/oliora/.docker/cli-plugins/docker-init
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/oliora/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.13.0
    Path:     /Users/oliora/.docker/cli-plugins/docker-scout

Server:
 Containers: 7
  Running: 0
  Paused: 0
  Stopped: 7
 Images: 13
 Server Version: 27.2.0
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 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 splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 8fc6bcff51318944179630522a095cc9dbf9f353
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
  cgroupns
 Kernel Version: 6.10.4-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 10
 Total Memory: 7.655GiB
 Name: docker-desktop
 ID: e389971f-bb54-4e02-9631-ec88b7c86f9a
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/oliora/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Anything else?

No response

idsulik commented 2 days ago

@oliora hi! Could you please provide a config file to reproduce the issue? I couldn't reproduce it using Docker Compose version v2.29.7-desktop.1

oliora commented 2 days ago

@idsulik sure, I can reproduce it with the following test.yaml compose file. Command is docker compose -f test.yaml config --no-interpolate --volumes.

networks:
  localnet:
    ipam:
      driver: default
      config:
        - subnet: $LOCAL_NET

services:
  frontend:
    build: ../../submodules/frontend
    restart: unless-stopped
    platform: linux/amd64
    ports:
      - "$LISTEN:$PORT:80"
      - "$LISTEN:$PORT_SSL:443"
    environment:
      HOST_NAME: $HOST_NAME
    networks:
      localnet:
    volumes:
      - ./configs/proxy_params:/etc/nginx/proxy_params
      - ./configs/nginx-defaults.conf:/etc/nginx/nginx-defaults.conf
idsulik commented 2 days ago

@oliora thank you! pushed fix for it https://github.com/docker/compose/pull/12282

oliora commented 2 days ago

Wow, so quick. Thank you!