Docker compose connection issue

I try to run a rails application in docker but I have an issue with docker-compose network, I think…

My Dockerfile looks like this:

  • How to pass host IP as environment variable when running a docker container on OS X
  • Docker not working after running MapReduce - AWS
  • Connect Docker Containers with remote debugger
  • How to create a Mongo Docker Image with default collections and data?
  • LDAP-Server with official docker support
  • npm scoped packages and private registry
  • FROM ruby:2.3-slim
    
    RUN apt-get update \
     && apt-get install -qq -y --no-install-recommends \
        build-essential \
        nodejs \
        libpq-dev \
        git \
        tzdata \
        libxml2-dev \
        libxslt-dev \
        ssh \
     && rm -rf /var/lib/apt/lists/*
    
    ENV APP_HOME /var/apps/books-store
    RUN mkdir -p $APP_HOME
    WORKDIR $APP_HOME
    
    ENV GEM_HOME /var/apps/books-store/vendor/bundle
    ENV PATH $GEM_HOME/bin:$PATH
    ENV BUNDLE_PATH $GEM_HOME
    ENV BUNDLE_BIN $BUNDLE_PATH/bin
    
    EXPOSE 3000
    

    my docker-compose.yml looks like this:

    version: '2'
    services:
      database:
        image: postgres
        volumes:
          - ./data/pgdata:/pgdata
        ports:
          - '5555:5432'
        env_file:
          - '.env'
      web:
        links:
          - database
        build: .
        volumes:
          - .:/var/apps/books-store
        ports:
          - '3000:3000'
        command: [bundle, exec, puma]
        env_file:
          - '.env'
        stdin_open: true
        tty: true
    

    When I try docker-compose up, from logs I see rails server starts successfully but when I try to access localhost:3000 from host browser it does not work and I could not understand why. What am I doing wrong?

    docker ps:

    407b59a2fa99   bookstore_web   "bundle exec puma"      About a minute ago  Up 41 seconds  0.0.0.0:3000->3000/tcp  bookstore_web
    1837fc3e3f387  postgres        "docker-entrypoint..."  About a minute ago  Up 49 seconds  0.0.0.0:5555->5432/tcp  bookstore_database_1
    

    docker-compose logs web:

    Attaching to bookstore_web_1
    web_1 | Puma starting in single mode...
    web_1 | * Version 3.6.2 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
    web_1 | * Min threads: 0, max threads: 16
    web_1 | * Environment: development
    web_1 | * Listening on tcp://0.0.0.0:9292
    web_1 | Use Ctrl-C to stop
    

  • Maintaining and supporting container base images
  • Can't run a command from Dockerfile or Docker Compose
  • Running gunicorn inside heroku docker
  • Datastax Opscenter requires restart when JMX auth is enabled?
  • Using GPU from a docker container?
  • ElasticBeanstalk: storing a bullet proof docker container
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.