skip to Main Content

Error when add an additional volume for the Ruby on Rails web app container

Hello, I’m programmming a containerized Rails app. Right now I’m doing the setup for the production environment.

My docker-compose.production.yml:

version: '3'

services:
  db:
    image: postgres
    volumes:
      - ./tmp/db:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: password

  web:
    build: .
    command: bash -c "rm -f tmp/pids/server.pid && bundle exec puma -C config/puma.rb"
    volumes:
      - .:/rails-lyrics-site
      - /rails-lyrics-site/node_modules
      - bundle:/usr/local/bundle
      - public-data:/rails-lyrics-site/public
      - log-data:/rails-lyrics-site/log
      - tmp-data:/rails-lyrics-site/tmp
    ports:
      - "3000:3000"
    depends_on:
      - db

  nginx:
    build:
      context: containers/nginx
    volumes:
      - public-data:/rails-lyrics-site/public
      - tmp-data:/rails-lyrics-site/tmp
    ports:
      - "80:80"
    depends_on:
      - web

volumes:
  bundle:
  public-data:
  log-data:
  tmp-data:

The problem is when I start with docker-compose -f docker-compose.production.yml up, I got the error:

Error

The problems will not occur when I remove the tmp-data volume from the web container. It seems that with this config, my tmp folder in the Rails source code is not being written into

Can anyone help me, please?

2

Answers


  1. You need to create the tmp/pids directory.

    Login or Signup to reply.
  2. Create tmp/pids at first time u run the docker compose

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search