Home>

I'm trying to build a rails environment on docker, but it doesn't work
Refer to the following site,
https://qiita.com/chisaki0606/items/a4b42af5c4735c94057aIt is in
docker-compose run web rails new. --force --no-deps --database = postgresql --skip-bundleTo
I tried it,
with fileNOtfounderrordocker.errors.DockerException: Error while fetching server API version: ('Connection aborted.'It will come out.
The first is in the commandpostgresqlI wondered if it would work if I changed the part to mysql, but it still doesn't work
Below, docker-compose.yml

version: '3'
services: services:
  db:
    image: postgres
    volumes:
      --./tmp/db:/var/lib/postgresql/data
    environment: environment:
      POSTGRES_PASSWORD:'postgres'
  web:
    build: ..
    command: bash -c "rm -f tmp/pids/server.pid&&bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      --.:/Myapp
    ports: ports:
      -"3000: 3000"
    depends_on:
      --db
FROM ruby: 2.6.5
RUN apt-get update -qq&&apt-get install -y nodejs postgresql-client
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"]

Below, entrypoint.sh

#!/bin/bash
set -e
# Remove a potentially pre-existing server.pid for Rails.
rm -f /myapp/tmp/pids/server.pid
# Then exec the container's main process (what's set as CMD in the Dockerfile).
exec "[email protected]"
source'https://rubygems.org'
gem'rails','~>5'


gemfile.lock is empty

  • Answer # 1

    https://qiita.com/azul915/items/5b7063cbc80192343fc0
    I was able to do it with reference to
    Apparently it was built with postgresql, but it seems that an error occurred because postgresql did not exist in the original environment.

Related articles