How do I configure docker compose to expose ports correctly?

I’m using docker and docker compose to run a clojure and a node app, alongside postgres.

The project is contained in the following folder structure.

  • getting error while trying to run docker image
  • Docker Best Approach for JAVA Web application (Linux , Oracle DB,Application Server)?
  • Docker Layer's On Disk Location
  • docker registry on localhost with nginx proxy_pass
  • Adding NPM and Bower to a Dockerize LAMP environment
  • Docker unsupported manifest mediatype
  • project/
    -- app/
    -- -- Dockerfile
    -- frontend/
    -- -- /Dockerfile
    -- docker-compose.yml

    The app/Dockerfile looks like so…

    FROM clojure:latest
    COPY . /usr/src/app
    WORKDIR /usr/src/app
    EXPOSE 9000
    CMD ["lein", "run", "migrate", "&&","lein", "run"]

    The frontend/Dockerfile looks like so …

    FROM node:5
    COPY . /usr/src/app
    WORKDIR /usr/src/app
    RUN npm install
    EXPOSE 8080
    CMD ["npm", "start"]

    And lastly the docker-compose.yml looks like…

      image: bradcypert/node
        - ./frontend:/usr/src/frontend
        - "8080:8080"
      image: bradcypert/clojure
        - ./app:/usr/src/backend
        - "9000:9000"
        - postgres
      image: postgres
        - "5432:5432"

    backend is failing for a separate reason, but the frontend seems to be running successfully, that being said, I’m unable to hit localhost:8080 and see the app. What do I need to do make this happen?

    Thanks in advance.

    Just to clarify, the command being run is docker-compose up

  • Concourse CI Pipeline giving error :- Get net/http: request canceled while waiting for connection
  • Install cron tasks in a docker run command
  • Windows 10: How to track 'docker pull' traffic calls using fiddler
  • Kubernetes vs Kubernetes on Mesos? [closed]
  • How to use Docker Remote API from a linux container to it's Windows host
  • wordpress Docker image with vagrant
  • One Solution collect form web for “How do I configure docker compose to expose ports correctly?”

    With boot2docker (on Mac or Windows), to access any port from localhost, you have to configure your VirtualBox VM in order to port-forward that port from the VM into the host.

    Your port mappings are correct, but you still need to make visible to your host (Mac) the one port you want to access from localhost (your Mac).

    See for instance “Using boot2docker to run Docker on a Mac or Windows” from Andrew Odewahn:

    enter image description here

    That way, you don’t have to find out what the IP of your machine is.
    (Which you can see with docker-machine ls followed by docker-machine ip <name>)

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