I would like to write a bash script that automates the following:
Get inside running container
docker exec -it CONTAINER_NAME /bin/bash
Execute some commands:
cat /dev/null > /usr/local/tomcat/logs/app.log
exit
The problematic part is when docker exec
is executed. The new shell is created, but the other commands are not executed.
Is there a way to solve it?
You can use
heredoc
withdocker exec
command:To use variables:
then use as:
You can simply launch
docker exec -it container_id cat /dev/null > /usr/local/tomcat/logs/app.log