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.

  • Start Filebeat using Supervisor
  • Docker set ipaddress and start services
  • docker(1.5.1) artifactory (3.x) registry management
  • Pass docker container name to app running inside container
  • Run two docker compose with same static ip on a host
  • Storm:java.lang.RuntimeException: Returned channel was actually not established
  • Why don’t they have

    expose:
      - "6379"
    

    in the redis container?

    version: '2'
    services:
      web:
        build: .
        ports:
         - "5000:5000"
        volumes:
         - .:/code
        networks:
          - front-tier
          - back-tier
      redis:
        image: redis
        volumes:
          - redis-data:/var/lib/redis
        networks:
          - back-tier
    

  • How to mount my local source file to docker container?
  • Accessing the same mongoDB instance from multiple Docker containers
  • Debugging Drupal on docker container using Atom
  • Why does the container created with - 'docker run -d alpine sleep infinity' goes into exited/stopped state?
  • Host Global Python Object in Docker Container
  • mysql cannot be started in Mgt Development Environment
  • 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.