This repository was archived by the owner on Nov 27, 2023. It is now read-only.
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
Compose CLI (v2) ignores some ports specified in docker-compose file when an override file is used. #2017
Description
Description
When using docker-compose.yml
file along with docker-compose.override.yml
file, docker-compose CLI only maps the first port specified in the docker-compose.yml
file.
Steps to reproduce the issue:
- Create a sample docker-compose project using the getting started tutorial. Else clone pratiksanglikar/compose-sample and jump to step 5.
- Modify the
docker-compose.yml
file to replace port entry"5000:5000"
by"5000"
to allocate host port dynamically. - Modify the
docker-compose.yml
file to add another port entry"6000"
.
The finaldocker-compose.yml
file looks like -
version: "3.9"
services:
web:
build: .
ports:
- "5000"
- "6000"
redis:
image: "redis:alpine"
- Add a
docker-compose.override.yml
file with the following contents -
version: "3.9"
services:
web:
container_name: python_webapp
- Start the app using
docker-compose up
command. - Inspect the container created for the python app using
docker inspect <container_id>
command. - Look at the
Ports
section.
Describe the results you received:
"NetworkSettings": {
"Ports": {
"5000/tcp": null,
"6000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "51220"
}
]
},
Describe the results you expected:
"NetworkSettings": {
"Ports": {
"5000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "51219"
}
],
"6000/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "51220"
}
]
},
Additional information you deem important (e.g. issue happens only occasionally):
- The issue happens only if you specify ports to be allocated dynamically.
- The issue happens only if you have the
docker-compose.override.yml
file.
Output of docker-compose --version
:
PS> docker-compose --version
Docker Compose version v2.0.0-rc.1
Output of docker version
:
PS> docker version
Client:
Cloud integration: 1.0.17
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:58:50 2021
OS/Arch: windows/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:52:10 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.19.0
GitCommit: de40ad0
Output of docker context show
:
PS> docker context show
default
Output of docker info
:
PS> docker info
Client:
Context: default
Debug Mode: false
Plugins:
buildx: Build with BuildKit (Docker Inc., v0.6.1-docker)
compose: Docker Compose (Docker Inc., v2.0.0-rc.1)
scan: Docker Scan (Docker Inc., v0.8.0)
Server:
Containers: 35
Running: 34
Paused: 0
Stopped: 1
Images: 9
Server Version: 20.10.8
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e25210fe30a0a703442421b0f60afac609f950a3
runc version: v1.0.1-0-g4144b63
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 5.10.43.3-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.56GiB
Name: docker-desktop
ID: 55EY:A7SS:SC32:BZYI:ZHI4:KHXV:5RVM:PKV5:IT6U:4HMN:X3NV:EIKE
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
Additional environment details (AWS ECS, Azure ACI, local, etc.):
Host machine: Windows
Containers: Linux