Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Repetition of ports from two different docker-compose files #473

Open
surajssd opened this issue May 29, 2017 · 1 comment
Open

Repetition of ports from two different docker-compose files #473

surajssd opened this issue May 29, 2017 · 1 comment

Comments

@surajssd
Copy link
Contributor

I have two docker-compose files which are similar:

$ ll
total 12
-rw-rw-r--. 1 foo foo   80 May 29 14:27 docker-compose1.yml
-rw-rw-r--. 1 foo foo   80 May 29 14:28 docker-compose2.yml

$ diff docker-compose1.yml docker-compose2.yml

which looks like this:

$ cat docker-compose1.yml 
version: "2"

services:
  web:
    image: centos/httpd
    ports:
    - "80:80"

When fed to libcompose, while libcompose is trying to merge the info, it should detect the repetition of ports and error out, but it goes forward and merges it:

$ libcompose  -f docker-compose1.yml -f docker-compose2.yml up
WARN[0000] Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose) 
INFO[0000] [0/1] [web]: Starting                        
INFO[0000] Recreating web                               
ERRO[0001] Failed Starting web : Error response from daemon: driver failed programming external connectivity on endpoint multiple_web_1 (747ef1b25524286894a48c8946e1a77dba778fd6dd0245163c8f40e7acaba5b2): Bind for 0.0.0.0:80 failed: port is already allocated 
ERRO[0001] Failed to start: web : Error response from daemon: driver failed programming external connectivity on endpoint multiple_web_1 (747ef1b25524286894a48c8946e1a77dba778fd6dd0245163c8f40e7acaba5b2): Bind for 0.0.0.0:80 failed: port is already allocated 
Error response from daemon: driver failed programming external connectivity on endpoint multiple_web_1 (747ef1b25524286894a48c8946e1a77dba778fd6dd0245163c8f40e7acaba5b2): Bind for 0.0.0.0:80 failed: port is already allocated

This works fine on docker-compose:

$ docker-compose  -f docker-compose1.yml -f docker-compose2.yml up
Recreating multiple_web_1
Attaching to multiple_web_1
web_1  | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
...

containers

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                NAMES
b98955e1a601        centos/httpd        "/run-httpd.sh"     7 seconds ago       Up 5 seconds        0.0.0.0:80->80/tcp   multiple_web_1

When the docker-compose files are like this:

$ cat docker-compose1.yml 
version: "2"

services:
  web:
    image: centos/httpd
    ports:
    - "80"

Just changed the port from "80:80" to "80".

Now starting this:

$ libcompose  -f docker-compose1.yml -f docker-compose2.yml up
WARN[0000] Note: This is an experimental alternate implementation of the Compose CLI (https://github.com/docker/compose) 
INFO[0000] [0/1] [web]: Starting                        
INFO[0000] Recreating web                               
INFO[0001] [1/1] [web]: Started                         
web_1 | AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.21.0.2. Set the 'ServerName' directive globally to suppress this message
...

containers:

$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                          NAMES
8ec86cfdd3c7        centos/httpd        "/run-httpd.sh"     8 seconds ago       Up 6 seconds        0.0.0.0:32776->80/tcp, 0.0.0.0:32777->80/tcp   multiple_web_1

The thing to note here is that it worked here because the same container port was exposed on two different ports on the host machine. Before it failed because it tried to map on the same port which was 80.

So the issue is solved by finding the repetition of ports in code before doing the deployment.

@surajssd
Copy link
Contributor Author

With respect to port it is not giving any errors but the data is repeated as well when using list form of specifying ports! See kubernetes/kompose#596 (comment) for more details!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant