How can I allow my Docker container to access the internet but block access to my host’s ports?

0
1
Asked By CuriousCat42 On

I'm setting up a Docker container using an isolated network and I want to run an application inside it that requires internet access. However, I've noticed that the container seems to have access to my host's listening ports (like SSH and SMB). I'm a bit concerned about this since I don't completely trust the app I'm running and want to prevent it from reaching those ports on my host machine. Is there a way to allow internet access to my container while keeping it from accessing my host's ports?

1 Answer

Answered By TechWhiz01 On

It sounds like you need to adjust your host's network settings. Instead of exposing your ports with something like `-p`, just don’t map any ports when you run your container. By default, Docker containers won't have access to your host ports unless specified, so as long as you don't expose them, you should be fine.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.