My own networking nightmare

I spent hours trying to set up a container with a public ip address and that could both communicate with the outside world and be contacted from the outside world.
I knew in order to use the –ip parameter, I had to set up my on user-defined docker network. So I thought of a user-defined network that could be a network or subnet containing the public addresses I meant to use.

What I tried first is the “bridge” driver. So I figured out that way the bridge I create inevitably has to be the default gateway, besides if I specify the “.1” address for the network I’m defining (with the “–gateway” parameter), inevitably that address is assigned to the bridge itself, so overriding the real situation, where a “.1” already exists and play its role. The maximum I could get on this way is I could assign the IP address to the container and the container could contact the outside world; unfortunately I find no way to contact that host from outside the host where dockerd is running. To be honest, I could do that once, but on a physical host on the same net and by adding a routing condition manually - that’s not a big deal…

Then I moved to “macvlan” driver, specifying the physical ethernet interface of the machine as a “parent” and the “.1” host of the real network as a default gateway. That way by issuing “ifconfig” I could se no added bridge interface, anyway newtorking for the containers seemed to work perfectly. I thought I had finally worked it out: public IP addresses assigned statically by me and containers perfectly acting as hosts on the Internet. But today misteriously the container I launched hours ago was no more reachable from outside, I could only access it and see it could contact hosts outside. I tried to configure all that stuff from scratch, but I’m back in the nightmare of containers with public addresses but not reachable.

I perfectly know I’m not enough knowledgeable with networking stuff, so I apologize if I all I told sounds as a newbie’s dilemma. But, please, give me a prompt to tame the monster. :wink: I have been working on this task till late hours and curiously I even had the joy of reaching somehow a finish line, but now the same context is driving me nuts. :frowning:

Thanks in advance!

A.