Skip to content
Advertisement

run multiple commands in docker after container start

how can I run /bin/run1.sh and /bin/run2.sh after the container startup! also, if you can tell me how can I send the logs of /bin/run1.sh and /bin/run2.sh to container logs!!

Docker file

JavaScript

entrypoint.sh

JavaScript

run1.sh

JavaScript

run2.sh

JavaScript

Advertisement

Answer

You can change ENTRYPOINT ["entrypoint.sh"] to ENTRYPOINT ["entrypoint.sh", "run1.sh", "run2.sh"] which will run your custom bash scripts

you also need to create the log.txt file if it does not exist and to add exec "$@" to resume the container’s main process

so your runX.sh files should look like this

JavaScript

note that if you are running DB migration on rails they should be logged in your application log which can be accessed through the docker container itself (get the docker id from docker ps then access the bash docker exec -it /bin/bash where you can navigate to /logs/{your environment}.log)

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement