'How do I run two commands as part of a single docker-compose "command"?
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?
Solution 1:[1]
Try to put all your commands inside an external sh file. in docker-compose use
command: /bin/sh -c "yourshfile.sh"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | fabio19933 |
