LAMP Stack on a single (unique) ip address

Hello,

Relatively new docker user here…I am looking to host a development stack on my docker server. I want to have the mysql, phpymyadmin and python images all running as separate containers, but have all of the individual port publishing happen on a singe ip address separate from the docker server.

I created a new bridge network and dropped all 3 containers on it, they have connectivity with each other, but i cannot access the database or phpmyadmin page from my laptop. I understand the easy way to fix this is to port map a random port on my docker server to the internal port of the container, and if I do this for 3306 and 80 it does establish connectivity between my laptop and the ports running inside of the docker container using the docker server’s IP address.

What I am looking to do is establish another IP address on the docker server, lets say my current docker server is 192.168.13.13, I want to be able to use 192.168.13.14 and map 3306 and 80 to that ip address dedicating it to the development stack.

Is that even possible to do?

Good morning,

the following would publish the container’s port 80 to all IP-addresses available on the Docker-host

docker run -p 80:80 -d nginx

To publish it only to a single ip-address (which has to be available on the host before) you can include the ip before the ports:

docker run -p 192.168.13.14:80:80 -d nginx

You can use a similar port mapping inside of a docker-compose.yml file. e.g.:

ports:
  - "192.168.13.14:80:80"

Another (different) idea/approach would be to use a load balancer (i.e. traefik) which forwards requests to the corresponding containers based on the hostname in the browser’s http-request.