Last active
June 5, 2020 15:11
-
-
Save GammaGames/a792d7d376817e4d913a1131ea486146 to your computer and use it in GitHub Desktop.
Pipe commands to docker container from host
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "foo" | |
# Pipe commands between patterns into container | |
sed -n "/^### SCRIPT START ###/,/^### SCRIPT END ###/p" "$0" | docker exec -i -e MESSAGE="bar" <id> /bin/bash - | |
echo "baz" | |
# Exit original script | |
exit | |
### SCRIPT START ### | |
#!/bin/sh | |
echo $MESSAGE | |
### SCRIPT END ### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Help from here: https://stackoverflow.com/a/62199630/3903479