- Main script
- copy a shell script to Docker a container
docker exec -it containerid /bin/bash
to login to the container- exec sub shell script
- Sub shell
- executing docker commands.
The sub shell script is working fine from the container, but is unable to exit the container even after we use the exit command. This makes it impossible to return to the main shell script after the subshell has executed.
Steps performed:
- tried to exit the command in and out the subshell but the container is not exiting.
- tried using
docker exec -i containerid /bin/bash
Mainscript
#!/bin/bash
# variable declaration
ssh to host user <<EOF
docker copy subshell to container
docker exec -it containerid /bin/bash
exec subshell.sh
exit
EOF
Subshell
#!/bin/bash
# variable declaration
# executing few docker commands and storing the output in files
exit # (expecting to come out of the container which is not working)