Rancher container taking over host IP

3/27/2019

I have 2 IP addresses in my rancher host (centos): 1.1.1.1 and 2.2.2.2

1.1.1.1 is the IP address I want to use to access the rancher UI and SSH into the host.

I want to use 2.2.2.2 for accessing containers for an application. I have 2 containers, one nginx and one ssh. I configured the containers to use hostport 80 mapped to 2.2.2.2:80 and 22 to hostport 2.2.2.2:22.

I have also changed the default run command for the rancher container to listen on port 80 and 443 of IP 1.1.1.1

If I go to my browser and access 1.1.1.1 I see rancher as expected, and if I access 2.2.2.2 I see my container app as expected.

However, if I try accessing 1.1.1.1:22 I end up connecting to the container ssh, which should be only listening to 2.2.2.2:22.

Am I missing something here? Is this a configuration issue on the host or the container? Can the container get access to something that it shouldn't even be aware of?

UPDATE

Let me try to clarify the setup:

Rancher is running in a host with 2 IP addresses. When I run rancher, I execute the following command, so it becomes attached to the first IP address:

docker run -d --volumes-from rancher-data --restart=unless-stopped -p 1.1.1.1:80:80 -p 1.1.1.1:443:443 rancher/rancher
docker run -d --privileged --restart=unless-stopped --net=host -v /etc/kubernetes:/etc/kubernetes -v /var/run:/var/run rancher/rancher-agent:v2.1.7 --server https://rancher1.my.tld --token [token] --ca-checksum [checksum] --etcd --controlplane --worker

I have 4 containers configured in the rancher UI, which I want pointing to 2.2.2.2:22 and 2.2.2.2:80, 2.2.2.2:2222 and 2.2.2.2:8080

These are 2 environments for an application. 22 and 80 are nginx and ssh containers for the LIVE environment (sharing a data volume between them) and the same thing for 2222 and 8080, with these being for a the QA environment. I use the ssh container to upload contents to the nginx container through the shared data volume.

I don't see a problem with this configuration, except the fact that when I configure the ssh machine to use port 22, when I try connecting to the host ssh, I get connected to the container ssh.

UPDATE 2

Here is a screenshot from the port mapping settings in the container: https://snag.gy/idTjoV.jpg

Container port 22 mapped to IP 2.2.2.2:222

If I set that to 2.2.2.2:22, SSH to host stops working, and ssh connections are established to the container instead.

-- Miguel Mesquita Alfaiate
docker
kubernetes
networking
rancher

0 Answers