Home>

(Host OS) windows10
rails6
ruby2.7
postgresql
UTF-8

I want to start the server with docker and access localhost
"Unable to access this site. Connection refused on localhost."
Will be said.

docker-compose up
Starting myapp_db_1 ... done
Starting myapp_web_1 ... done
Attaching to myapp_db_1, myapp_web_1
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database;Skipping initialization
db_1 |
db_1 | 2020-09-27 09: 05: 55.252 UTC [1] LOG: starting PostgreSQL 13.0 (Debian 13.0-1.pgdg100 + 1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) ) 8.3.0, 64-bit
db_1 | 2020-09-27 09: 05: 55.253 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
db_1 | 2020-09-27 09: 05: 55.254 UTC [1] LOG: listening on IPv6 address "::", port 5432
db_1 | 2020-09-27 09: 05: 55.260 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
db_1 | 2020-09-27 09: 05: 55.266 UTC [24] LOG: database system was shut down at 2020-09-27 09:05:46 UTC
web_1 | =>Booting Puma
web_1 | =>Rails 6.0.3.2 application starting in development
web_1 | =>Run `rails server --help` for more startup options
web_1 | Puma starting in single mode ...
web_1 | * Version 4.3.6 (ruby 2.7.1-p83), codename: Mysterious Traveler
web_1 | * Min threads: 5, max threads: 5
web_1 | * Environment: development
web_1 | * Listening on tcp: //0.0.0.0:3000

Probably due to "database system was shut down at 2020-09-27 08:48:28 UTC" but I don't know how to fix it. Please give me some advice.

docker-compose ps
The specified path can not be found.
     Name Command State Ports
-------------------------------------------------- -------------------------------
myapp_db_1 docker-entrypoint.sh postgres Up 5432/tcp
myapp_web_1 entrypoint.sh bundle exec ... Up 0.0.0.0:3000->3000/tcp
FROM ruby: 2.7.1
RUN apt-get update -qq&&apt-get install -y nodejs postgresql-client
RUN apt-get update&&apt-get install -y curl apt-transport-https wget&&\
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add-&&\
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list&&\
apt-get update&&apt install -y yarn
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash-&&\
apt-get install nodejs
RUN mkdir/myapp
WORKDIR/myapp
COPY Gemfile/myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
COPY./Myapp
# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod + x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000
#Start the main process.
CMD ["rails", "server", "-b", "0.0.0.0"]
version: '3'
services: services:
  db:
    image: postgres
    volumes:
      --web_postgre:/var/lib/postgresql/data
    environment: environment:
      POSTGRES_PASSWORD: 3246xkxh
  web:
    build: ..
    command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
    volumes:
      --.:/Myapp
    ports: ports:
      -"3000: 3000"
    depends_on:
      --db
volumes:
  web_postgre:
    external: true
  • Answer # 1

    For docker toolbox

    docker-machine ip default


    Check the IP address with
    http: //: 3000 /
    Should have done

    Instead, I got the error Webpacker :: Manifest :: MissingEntryError. I have another question.

  • Answer # 2

    if,web_postgreIf you don't have the data you need inside
    Wouldn't it improve if you delete the contents and restart it?

    docker-compose down -v
    rm -rf web_postgre
    docker-compose up

    Reference: docker-compose down | Docker documentation

    If this improves,
    For some reasonweb_postgreIt is possible that the data in was in an abnormal state.