Docker Community Forums

Share and learn in the Docker community.

Syntax for "command" option in docker-compose


(Belgoros) #1

I have a weird behaviour when starting one of the containers (web) defined as follows in docker-compose.yml file:

version: '3'

services:
  web:
    build: .
    links:
      - database
      - redis
    ports:
      - "3000:3000"
    volumes:
      - .:/usr/src/app
    env_file:
      - .env/development/database
      - .env/development/web
    command:
      - |
        rails db:reset
        rails db:init_data
        rails s -p 3000 -b '0.0.0.0'
  redis:
    image: redis
  database:
    image: postgres
    env_file:
      - .env/development/database
    volumes:
      - db-data:/var/lib/postgresql/data
volumes:
  db-data:

Here is Dockerfile:

FROM ruby:2.5.1

LABEL maintainer="DECATHLON"

RUN apt-get update -yqq
RUN apt-get install -yqq --no-install-recommends nodejs

COPY Gemfile* /usr/src/app/
WORKDIR /usr/src/app

RUN echo "gem: --no-rdoc --no-ri" >> ~/.gemrc
RUN bundle install

COPY . /usr/src/app/

When I start it docker-compose up --build(or without --build), webservice fails to start:

Creating network "myapp_default" with the default driver
Creating myapp_redis_1    ... done
Creating myapp_database_1 ... done
Creating myapp_web_1      ... error

ERROR: for myapp_web_1  Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"rails  s -b \\\"0.0.0.0\\\"\\n\": executable file not found in $PATH": unknown

ERROR: for web  Cannot start service web: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"rails  s -b \\\"0.0.0.0\\\"\\n\": executable file not found in $PATH": unknown
ERROR: Encountered errors while bringing up the project.

It worked fine yesterday but not this morning (no changes were made since yesterday).
The project code source can be found on GitHub.

I run it with:

  • Docker version 18.03.1-ce-mac65 (24312)
  • macOS 10.13.3

What"s wrong with that ? Thank you.