How to expose in a network?

The below example is from the docker-compose docs.

From my understanding they want to have redis port 6379 available in the web container.

  • How do you remove the deploymentConfig, image streams, etc using Openshift OC?
  • Docker container can't be reached from another PC
  • Running gunicorn inside heroku docker
  • Travis vs fastboot tests: spawn /bin/sh ENOENT
  • Jenkins auto build by Github webhook is not working
  • docker-compose: how to map few ip to few containers
  • Why don’t they have

      - "6379"

    in the redis container?

    version: '2'
        build: .
         - "5000:5000"
         - .:/code
          - front-tier
          - back-tier
        image: redis
          - redis-data:/var/lib/redis
          - back-tier

  • How to limit Docker filesystem space available to container(s)
  • Mesos cannot deploy container from private Docker registry
  • Nginx, PHP-FPM, MySQL and Symfony using Docker : Nginx 502 Bad Gateway and Symfony No route found exception
  • Docker installation on Ubuntu 12.04 -> cannot connect to daemon
  • Cannot publish: Visual Studio 2015 Tools for Docker
  • Access container name in Nginx configuration file
  • 2 Solutions collect form web for “How to expose in a network?”

    From the official Redis image:

    This image includes EXPOSE 6379 (the redis port), so standard
    container linking will make it automatically available to the linked
    containers (as the following examples illustrate).

    which is pretty much the typical way of doing things.

    Redis Dockerfile.

    You don’t need links anymore now that we assign containers to docker networks. And without linking, unless you publish all ports with a docker run -P, there’s no value to exposing a port on the container. Containers can talk to any port opened on any other container if they are on the same network (assuming default settings for ICC), so exposing a port becomes a noop.

    Typically, you only expose a port via the Dockerfile as an indicator to those running your image, or to use the -P flag. There are also some projects that look at exposed ports of other containers to know how to talk to them, specifically I’m thinking of nginx-proxy, but that’s a unique case.

    However, publishing a port makes that port available from the docker host, which always needs to be done from the docker-compose.yml or run command (you don’t want image authors able to affect the docker host without some form of local admin acknowledgement). When you publish a specific port, it doesn’t need to be exposed first.

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