I am currently developing Ruby on rails in a Docker environment, but suddenly I cannot connect to localhost.
$curl localhost:3000
curl:(7) Failed to connect to localhost port 3000: Connection refused
Below is the environmental information.
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=532"
- "DATABASE_USER=*******"
- "DATABASE_PASSWORD=******"
links:
- db
volumes:
- "./app:/app"#Setting Shared Folders
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
RUNgem install rails
RUN mkdir/app
WORKDIR/app
I would appreciate it if you could let me know if anyone knows the cause.
Thank you for your cooperation.
Note:
The forwarding of the Docker side port is normal, so the Rails side is likely to have a problem.
$docker-compositions
Name Command State Ports
--------------------------------------------------------------------------------
db_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->532/tcp
web_1 irb Up 0.0.0.0: 3000 - > 3000 / tcp
The web_1
container is up in irb, but is the server running?
Puma or WEBrick.
How about adding command
to docker-compose.yml
.
web:
build —web
ports:
- "3000:3000"
command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0" ]
...
If the server is running, please show me the log.
© 2024 OneMinuteCode. All rights reserved.