Docker Community Forums

Share and learn in the Docker community.

Get Ip of host instead of docker engine

Hi everybody,
I’m relatively new to docker but I’m trying to create an application in python which analyzes some FTP log. I was able to create an easy vsftpd docker using fauria/vsftpd. My problem is that when I look into the log of the vsftpd server I see that all the requests have been done from the docker gateway.

For example, if client A with IP = 192.168.0.5 does a request to docker B which have gateway = 172.21.0.1 and IP = 172.21.0.2 in the log I will have something like this:
Mon Mar 23 12:02:21 2020 [pid 47] [username] OK LOGIN: Client “172.21.0.1”

And this makes sense, but is there a way to know which particular host has done that request? I need to get something like:
192.168.0.5 has requested throw ftp this file: /example/ at the docker with IP 172.21.0.2

The way to accomplish this, is to set the containers network to “host”

And in this way I would be able to create more than one ftp server or just one? my goal is to be able to create 2 or 3 different ftp server running in the same machine at the same time

EDIT: I add in the docker-compose: network_mode: host, the two ftp server boot up correctly and everything seem fine. But now, how can I access them throw ftp? On portrainer I couldn’t see their ip…

EDIT 2: after a few seconds the containers stop with exit code 2

yes that will be an issue, as this will use the port as the services creates, which is 21 in this case.

Its not an easy fix, but you could create a dockerfile and change the port of the ftp server.
but
i have never tried this, but you could try and disable the userland-proxy:
create the file: /etc/docker/daemon.json
put this in it: { “userland-proxy”: false }

restart docker, and then try and run the container as you did before, without --network=host