I have two scripts that I would like to execute.
Script 1: A script that executes docker run (needs to stay active because if it is closed the docker container stops running)
Script 2: A script that runs docker exec and gets into the docker shell
Problem: I need to run script 1 and script 2 in separate shells because script 1 needs to stay active and cannot be closed.
- Separating the scripts into two separate files and then running both scripts from one file
- sh script1.sh & sh script2.sh
CodePudding user response:
Just run it as one big script.
When executing/running the docker container use the --detach
or -d
flag.
This ensures, that the container does not stay active in the terminal but moves into the background (it keeps running!).
The docker command would look something like
docker run -d ...