How to make docker container to be accessed only in intranet
I want to run a docker container in my server, and expose a specific port to other server in the same intranet. But I don’t want my container can be accessed by internet outside.
Is there any solution for my situation?
Any help will be appreciated.
One Solution collect form web for “How to make docker container to be accessed only in intranet”
If your host computer is running on Windows, you can configure firewall to allow that specific port to be accessed only from that machine.
Another option is to configure boot2docker (via iptables) to restrict access only to specific IP address. But I think it works only for the current session: you have to edit boot2docker image and add it to be used permanently. And the drawback is that all docker images running in docker inside boot2docker would be affected with this change.
So, my suggestion is to restrict access on host computer side, such as:
c:\>boot2docker init c:\>boot2docker up c:\>boot2docker ssh -L 0.0.0.0:8080:localhost:8080 docker@boot2docker:~$ docker run -p 8080:8080 myContainer
And restrict port 8080 on firewall level of your host computer.