docker bind socket to outside port

I’m using docker. Inside docker I have app that binds listening socket to ip of outside machine (ip of machine where I have docker running). is there any way I can make such listening socket work? that’s bound to outside ip address ( and not docker’s eth0 (

  • Docker: Dockerizing apache virtual hosts
  • Building Dockers with Ansible docker_image
  • Downgrading from PHP 7 to PHP 5 on a Docker Server
  • How do I display output from Python application running inside Docker container?
  • EOF Error :: when docker command is executed
  • Django & WordPress - wp-admin redirect issue
  • AWS EC2 Docker Volumes lsblk
  • How do I setup a read only private docker registry using just HTTP?
  • Mounted docker.sock login not stored
  • Inconsistent runtime kernel parameters in DOCKER container and on host
  • Download all dependencies, plugin dependencies, compilers, etc. with Maven?
  • How can I create dependent Docker images with Docker Maven plugin?
  • 2 Solutions collect form web for “docker bind socket to outside port”

    When you run the container map the port to the external port you want to reach it on. docker run -p 80:80 myapp This will let you access the docker container at The command format is -p {external port}:{internal app port}.

    For further clarification. To access any application inside a container you will want to expose the port, see this. Essentially you map a port from the container to the host o/s.

    Example: You have an application running on port 8080 in your container, but you want to access it with your host ip at port 8000. You would run your app like so docker run -p 8000:8080 myapp. This will expose port 8080 to your host o/s as port 8000 at which point you could reach it at {host ip}:8000.

    Okay fixed myself:
    add new ip via “ip addr add”, then make iptable rule to preroute incoming packets to that ip and thats all 🙂

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