compose: Compose config with --no-interpolate fails as it tries to validate environment variables as ports

Description of the issue

When trying combine compose and override files with docker-compose config --no-interpolate, I get an validation error in the ports block for a service that uses environment variables.

Context information (for bug reports)

Output of docker-compose version

docker-compose version 1.25.0, build unknown

Output of docker version

Docker version 19.03.8, build afacb8b7f0

Output of docker-compose config (Make sure to add the relevant -f and other flags) The issue relates to config!

Steps to reproduce the issue

  1. Small example file
     #compose.yml
     version: '3'
     services:
        test:
          image: hello-world
          ports:
              - "${DUMMY_PORT}:${DUMMY_PORT}"
    
  2. docker-compose -f compose.yml config --no-interpolate

Observed result

services.test.ports is invalid: Invalid port "${DUMMY_PORT}:${DUMMY_PORT}", should be [[remote_ip:]remote_port[-remote_port]:]port[/protocol]

Expected result

version: '3'
services:
  test:
    image: hello-world
    ports:
      - "${DUMMY_PORT}:${DUMMY_PORT}"

Stacktrace / full error message

compose.config.config.find: Using configuration files: ./compose.yml
ERROR: compose.cli.main.main: The Compose file './compose.yml' is invalid because:
services.test.ports is invalid: Invalid port "${DUMMY_PORT}:${DUMMY_PORT}", should be [[remote_ip:]remote_port[-remote_port]:]port[/protocol]

Additional information

OS version / distribution, docker-compose install method, etc. Pop! OS 20.04, using system packages for docker / docker-compose.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 6
  • Comments: 15

Commits related to this issue

Most upvoted comments

Update: error appears for every variable in ports section, equally in cases: - ${VARIABLE}, - 42:${VARIABLE}, - ${VARIABLE}:42 and ${FIRST_VARIABLE}:${SECOND_VARIABLE}