Docker Community Forums

Share and learn in the Docker community.

Docker Compose Networking Help Please

I cannot find an example of this anywhere. Perhaps I am not searching for it correctly. Regardless, I need a little help or a push in the right direction.

My goal:
Create a Docker Compose Application that uses a single static IP address on an existing network, however exposes ports from multiple containers within the application.

I cannot seem to figure out the syntax to do this natively in Docker Compose. Perhaps it’s not possible.

I have also tried to create a single proxy container within the Docker Compose Application to assume the static ip address, but I cannot get multiple networks working

Here is a simplified example of database and app server. I want to be able to expose both 80 and 1433 on a single static ip address on my existing network

version: ‘3’

services:
app:
ports:
- 80:80

mssql:
ports:
- 1433:1433

networks:
qnet-static:
external:
name: qnet-static-eth1-ec3261

Greetings!

Do you mean ur docker application should have a different ip than the machine you are running your docker application on, e.g.
Machine docker is running on: 192.168.178.111
Compose app on Docker Machine: 192.168.178.112

Not sure if that is possible.

I have set the ip of my pc that docker is running on to static and then i could reach every application(database and app) on the in compose defined ports:

Machine docker is running on: 192.168.178.111
mssql: 192.168.178.111:1433
app: 192.168.178.111:80

Hope i could help you. Maybe i didnt understand the question tho :slight_smile: