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?

  • How do I use map[string]struct{}
  • Tensorflow serving with Docker while the client is a Windows 7 machine
  • Ubuntu 16.10 in Docker 1.12 claims there is no socket for MySQL
  • connection issues between apacheds and tomcat docker containers
  • How to share data between host and containers using volumes in Docker Compose
  • How can I map a volume in a running docker container?
  • Any help will be appreciated.

  • Starting mysql container using docker machine with virtual box shared folder
  • How to exit “docker run” containers once the script those containers execute calls exit()
  • How should I launch ipython notebook from Docker once a session has been launched?
  • docker is not VM , why container need base image OS ? [closed]
  • Scaling Rivescript chats
  • Error 500 when running exec start with Docker Remote API
  • 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
    docker@boot2docker:~$ docker run -p 8080:8080 myContainer

    And restrict port 8080 on firewall level of your host computer.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.