0

What I want

I want to create Rails projects with docker

Problem

When I command this, The error is happend

 sudo docker-compose run api rails new . --force --no-deps --database=po stgresql
standard_init_linux.go:211: exec user process caused "no such file or directory"

refer to URL

standard_init_linux.go:190: exec user process caused "no such file or directory" - Docker

code

docker-compose

FROM ruby:2.6.5
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
RUN mkdir /api
WORKDIR /api
COPY ./api/Gemfile /api/Gemfile
COPY ./api/Gemfile.lock /api/Gemfile.lock
RUN bundle install
COPY ./api/ /api

# 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"]

docker-compose.yml

version: '3'
services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
  api:
    build:
      context: ./
      dockerfile: ./docker/Dockerfile
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
    volumes:
      - ./api:/api
    ports:
      - "3000:3000"
    depends_on:
      - db

version

docker-compose v3 rails v6

How can I fix it? Thank you

Mikinovation
  • 107
  • 1
  • 1
  • 8
  • 1
    What have you done so far to debug this? Does your Rails application work without Docker involved at all? – David Maze Dec 21 '19 at 02:27
  • The building is success but it will exit soon. when I log, "api_1 | standard_init_linux.go:211: exec user process caused "no such file or directory" showed – Mikinovation Dec 21 '19 at 02:56
  • 1
    Can I ask why you’re trying to create a new rails project directly in docker? It’s far simpler to create the project in rails normally then run with `rails s` – TomDunning Dec 21 '19 at 10:20
  • https://github.com/ledermann/docker-rails start from here – Penguin Dec 22 '19 at 17:40

0 Answers0