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
- Small example file
#compose.yml version: '3' services: test: image: hello-world ports: - "${DUMMY_PORT}:${DUMMY_PORT}"
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
- fix error on ports validation with --no-interpolate flag. add tests. #7964 Signed-off-by: Sokolova Olga <olg_sok@mail.ru> — committed to o-sokolova/compose by o-sokolova 3 years ago
- quick fixed generation until https://github.com/docker/compose/issues/7964#issue-755199552 is fixed — committed to pseusys/HogWeedGo by pseusys 2 years ago
Update: error appears for every variable in
ports
section, equally in cases:- ${VARIABLE}
,- 42:${VARIABLE}
,- ${VARIABLE}:42
and${FIRST_VARIABLE}:${SECOND_VARIABLE}