Unable to access Rails+docker-compose localhost

Asked 1 years ago, Updated 1 years ago, 105 views

I'm trying to develop the rails application using docker.

docker-compose run web rails db:migrate
I was able to verify that the database was created by running , but when I accessed localhost:3000, I saw the following:

 This page is not working No data was sent from localhost.
ERR_EMPTY_RESPONSE

As an assumption, we expect the rails application default page to appear.

I'd like someone to give me some advice.

docker-compose.yml

version: '3'
services:
  db:
    image —postgres
    environment:
      POSTGRES_USER: 'postgresql'
      POSTGRES_PASSWORD: 'postgresql-pass'
    restart —always
  web:
    build:.
    command: bundle exec rails -p 3000-b '0.0.0.0'
    volumes:
      - .:/myapp
    ports:
      - "3000:3000"
    depend_on:
      - db

Dockerfile

 FROM ruby: 2.3.3
RUN apt-get update-qq & apt-get install-y build-essential libpq-dev nodejs
RUN mkdir /myapp
WORKDIR/myapp
COPY Gemfile/myapp/Gemfile
COPY Gemfile.lock/myapp/Gemfile.lock
RUN bundle install
COPY.

Tried

Accessed at http://0.0.0:3000 → No change

Accessed at http://127.0.0.1:3000 → No change

docker-composer run webrails already existed

docker-compose exec webbash entered the virtual environment and typed the following command:
The standard HTML file was retrieved, so it seems to be working properly in a virtual environment.

 curl localhost:3000

〜〜〜
 <h1>Yay! You&rsquo;reon Rails!</h1>
〜〜〜

ruby-on-rails docker docker-compose

2022-09-30 14:16

1 Answers

I was building a separate swarm cluster and it was disturbing.
The docker warm leave -- force command pulled out of the swarm cluster and ran docker up-d again, and it worked.


2022-09-30 14:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.