Skip to content

Instantly share code, notes, and snippets.

@GammaGames
Last active June 5, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GammaGames/a792d7d376817e4d913a1131ea486146 to your computer and use it in GitHub Desktop.
Save GammaGames/a792d7d376817e4d913a1131ea486146 to your computer and use it in GitHub Desktop.
Pipe commands to docker container from host
#!/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 ###
@GammaGames
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment