Docker Community Forums

Share and learn in the Docker community.

Docker Compose IP specify questions for clarification


(Rahlquist) #1

Hello,

New to docker overall but was enthusiastically encouraged by a friend so I gave it a shot. I have taken a look into it but I have some questions about specifying IP’s.

What I would like to do is assign a container an ip that exists as a virtual IP on my host. So my physical ubuntu install has more that one IP. Like so;
eno1 192.168.0.10
eno1:1 192.168.0.4
eno1:2 192.168.0.5

So now I want to create a container for say Subsonic audio server and hang it off 192.168.0.4

And I want to create a OwnCloud container and hang it off 192.168.0.5

I do this now on a server without Docker and each service while more resource intensive, they cant each run their service off port 80 on their respective IP’s.

Is this possible with compose? Will it still wind up being a bridged situation? I seem to be finding mixed information online.


(David Maze) #2

When you run the container, in plain docker run syntax, you’d specify the specific host IP address in an docker run -p 192.168.0.4:80:80 option. In the docker-compose.yml syntax it looks pretty much the same,

subsonic:
  image: me/subsonic
  ports: ["192.168.0.4:80:80"]

(Rahlquist) #3

Thank you, that worked perfect. I guess i was over-complicating it.