Access my nginx container from my external PC

Hello everyone,

I am new to Docker world.

I built myself a small PC to play with Docker, on Ubuntu, it works very well. At the same time I have my everyday PC, under Windows 11. I can access my Ubuntu Docker PC via an SSH connection, no worries it works very well.

For information, on my Windows 11 PC, the default gateway is 192.168.1.1.

If I create an nginx container for example, on my Ubuntu, I can access it via localhost:8080 for example. But how do I access it from my Windows 11 PC?

I tried to play with the network settings but without success, I read a lot of tutorials but I didn’t find simple solutions, or I didn’t understand anything :slight_smile:

Can you guide me?

Thanks a lot for your help.

Hi :slight_smile:

You should be able to access it via ubuntu-ip:8080, but it depends on how you started the container, care to share? :slight_smile:

Oh my god i’m so ashamed :face_with_hand_over_mouth:

Obviously you have to call the address of the ubuntu on port 8080

For information I launched my container with the following command:

docker run -d -p 8080:80 nginx:latest

Sincerely sorry for this post and a big thank you for the clear and fast answer :wink:

I take this opportunity to ask another question … I hope more interesting :grinning:

When I try to assign an IP address to my container with the following command:
docker run -d --name c1 -p 192.168.1.100:8080:80 nginx:latest

I have the following error message:

docker: Error response from daemon: driver failed programming external connectivity on endpoint c1 (fe6e52aec1e88aa75f177f814fd8feae2fdf7e498a3dd6de4b0ca2dec3ffbf6a): Error starting userland proxy: listen tcp4 192.168.1.100:8080: bind: cannot assign requested address

No problem :smiley: its all new and you will properly get more eureka moments along the way :slight_smile:

Can you explain what you want to do, do you want to get the container an new IP from your dhcp or?

The thing you’re trying to do there, is to map the container to an interface on the host 192.168.1.100, that isnt there

I have the impression that I’m on the wrong way… In fact, I plan to set up a small website in a container and to be able to access it via my public address.

In this case, it is better to “play” with ports and work with port forwarding?

It really depends on how you want to do it.
You could use macvlan to assign an ip from your dhcp directly to the container.

But i think what most people do, is use different ports, and use something in front to route it to the specific container, fx. traefik, Nginx Proxy Manager or another reverse proxy to route, my.domain.com → host/container:8080