Reputation: 421
I got this error suddenly. Before getting this error I could connect.
$ curl localhost:3000
curl: (7) Failed to connect to localhost port 3000: Connection refused
My environments are below.
OS:macOS Sierra 10.12.6 Docker version 18.06.1-ce, build e68fc7a
docker-compose.yml
version: "3"
services:
web:
build: web
ports:
- "3000:3000"
environment:
- "DATABASE_HOST=db"
- "DATABASE_PORT=5432"
- "DATABASE_USER=********"
- "DATABASE_PASSWORD=********"
links:
- db
volumes:
- "./app:/app" #共有フォルダの設定
stdin_open: true
db:
image: postgres:10.1
ports:
- "5432:5432"
environment:
- "POSTGRES_USER=********"
- "POSTGRES_PASSWORD=********"
Dockerfile
FROM ruby:2.5.0
RUN apt-get update && apt-get install -y build-essential libpq-dev postgresql-client
RUN gem install rails
RUN mkdir /app
WORKDIR /app
If you have some suggestion to solve this please tell me. Thanks.
Upvotes: 2
Views: 1547
Reputation: 2573
you should specify your command for running application like: bundle exec rails s -p 3000 -b '0.0.0.0'
which run your server on port 3000
and bind it to local network 0.0.0.0
.
so you should write it in your Dockerfile
in the last line:
RUN bundle exec rails s -p 3000 -b '0.0.0.0'
Upvotes: 2