How can I set a static ip address inside the docker “rocketchat_default” network so i can proxy it easy, without checking the possible new IP each reboot or update of RC?
btw am use the docker-compose option and it works great!
it would be easier if some sort of documentation would be available, especially if you are new to docker.
I found that if an existing docker network is in use (like with RC (cause of the communication between Mongo / RC & Hubot)) you can use the docker network external (https://docs.docker.com/compose/networking/ @ the bottom of the page). after setting the network config i can give each docker compose component it owns static ip (within the rocketchat_default network range).
With compose you can just use the service name as it’ll be automatically resolved to the correct IP. No need to assign any static IPs.
Hi, well this isn’t working for me, it is not possible to resolve service names into IP addresses
ping: rocketchat: Temporary failure in name resolution
Are you doing this from inside one of the containers that share the same external network as the container defined in rocketchat do?
no, the ping command is just from the host the containers are running on.
Let me walk you through this alright?
Without docker-compose
, when you use a custom network (created using docker network create
command), for each container that’s connected to this one, one can communicate with another using just their hostname.
You can test this by creating a network, then spawn two containers, both attached to this network, and set two different hostnames.
docker network create net
docker run -d --rm --name alp0 --hostnane con0 --network net alpine sleep 1d
docker run -d --rm --name alp1 --hostnane con1 --network net alpine sleep 1d
Now you attach to one container and try to ping the other one using just the hostname. Like the following
docker exec -ti alp0 ash
(In alp0) > ping con1
In short, the hostname gets automatically resolved if using custom docker networks (i.e. not the default bridge network).
Now with docker-compose
, you don’t have to specify any hostname. The service name IS the hostname. I hope this is clear now.
Are you using a reverse proxy ? If yes, how?
will this also work between host and containers?
my host is the reverse proxy (nginx) to the containers (now specified with the local ip of the container and port).
Why are you using native nginx instead of an nginx container?
am still transitioning from LXC to docker.
With LXC i used the same ‘strategy’ to proxy the domains into the containers.
Thanks for the suggestion, i going to try out the reverse proxy also in a docker container, shouldn’t be that hard.
Here’s something to help you on that