Issue with port binding

Hello Team,

It’s my first time with rancher, i use it with version 0.63 and i have wait for the version 1.0

I try today to install two wordpress from the catalog.

The first wordpress is OK

But the second display an error of binding the port 80.

so after checking, i have change the port mapping (from the UI) for the first wordpress, but when i do a docker ps it’s always port 80

Here is the example

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0fa23f389c6 mariadb:latest “/docker-entrypoint.s” 17 minutes ago Up 17 minutes 3306/tcp r-wordpress2_db_1
7e863020cbbd wordpress:latest “/entrypoint.sh apach” 19 minutes ago Up 46 seconds 0.0.0.0:80->80/tcp r-wordpress_wordpress

I change the 0.0.0.0:80 to 0.0.0.0:6666 in the UI but it’s not changing :frowning: do you know this issue?

Regards

Docker PS will never change. We manage the ports with iptables. Is your service accessible in port 6666? Also, you shouldn’t need the 0.0.0.0.

Please read the note in the port mapping section.

http://docs.rancher.com/rancher/rancher-ui/applications/stacks/adding-services/#port-mapping

thank you denise, i understand more now.

But if i would like to deploy two wordpress. The first one start ok, the second one display this error :slight_smile:

Stopping (500 Server Error: Internal Server Error ("failed to create endpoint c340f246-4db7-4dc3-ab63-a27bf4be3aee on network bridge: Bind for 0.0.0.0:80 failed: port is already allocated")) Host:
So i don’t know what i can do :frowning:

When you create the Wordpress service, don’t specify an external port to listen on. If you do specify the port, it has to be open on the host.

You’re trying to start 2 services on the same host using the same port, so it’s not working.

See for details: http://docs.rancher.com/rancher/rancher-ui/applications/stacks/adding-services/#port-mapping

To achieve what I think you want, copy and paste the docker-compose.yml and rancher-compose.yml from the Wordpress App and create a new Application, paste those, then change ports: 80:80 to ports: 80. This will select a random port, then put a load balancer in front of it.

wordpress:
  image: wordpress
  links:
    - db:mysql
  ports:
    - 80

db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example

I take that back, apparently this WILL NOT accomplish your goal, because I just tried it.

Rancher appears to assign a random port to the service, not the container. I’m not sure if there’s any way around this, but I hope there is.

@caradou How many hosts do you have that have port 80 available for the wordpress app? It sounds like you only have 1 host available, but you want 2 services to use the same port on the host, which is not allowed.

You can opt to not expose any ports on the wordpress service. Add a load balancer to point to the wordpress service and use a source and target port of 80. Then the load balancer would direct the traffic from the single host at port 80 to the wordpress service and round robin between container A and B of the wordpress service.

You don’t need to publish a port at all in the wordpress container. A load balancer talks to the container over the overlay network and can talk to any port the container is listening on.