skip to Main Content

I’m using Docker v. 20.10.12. I have set up this container in my docker-compose file …

  web:
    restart: always
    build: ./my-web
    ports:
      - "3000:3000"
    expose:
      - '3000'
    env_file: ./my-web/.docker_env
    command: rm -f /app/tmp/pids/*.pid && foreman start -f Procfile.hot
    volumes:
    - ./my-web/:/app
    depends_on:
      - db

When I start using “docker-compose up”, the above container always displays this message

my-web-1 exited with code 0

There is no other info before that. However, if I change the command to be

command: tail -F anything

And then log in to the docker container, I can run

rm -f /app/tmp/pids/*.pid && foreman start -f Procfile.hot

just fine without an errors. How would I run that as part of starting up my Docker container without having to do the manual steps from above?

2

Answers


  1. Try to put all your commands inside an external sh file.
    in docker-compose use

    command: /bin/sh -c "yourshfile.sh"

    Login or Signup to reply.
  2. You can do

    command: /bin/sh -c "rm -f /app/tmp/pids/*.pid && foreman start -f Procfile.hot"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search