(ホストOS)windows10
rails6
ruby2.7
postgresql
UTF-8
dockerでサーバーを起動してlocalhostにアクセスしたいのですが
「このサイトにアクセスできませんlocalhost で接続が拒否されました。」
と言われてしまいます。
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 Traveller web_1 | * Min threads: 5, max threads: 5 web_1 | * Environment: development web_1 | * Listening on tcp://0.0.0.0:3000
おそらく「database system was shut down at 2020-09-27 08:48:28 UTC」が原因ですがどうすれば解決するかわかりません。アドバイスお願いします。
docker-compose ps 指定されたパスが見つかりません。 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: db: image: postgres volumes: - web_postgre:/var/lib/postgresql/data environment: POSTGRES_PASSWORD: 3246xkxh web: build: . command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"] volumes: - .:/myapp ports: - "3000:3000" depends_on: - db volumes: web_postgre: external: true
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。