Skip to content

Instantly share code, notes, and snippets.

@albertywu
Last active March 2, 2021 15:56
Show Gist options
  • Select an option

  • Save albertywu/ce473ef360048ce92ee8cc65d189ab42 to your computer and use it in GitHub Desktop.

Select an option

Save albertywu/ce473ef360048ce92ee8cc65d189ab42 to your computer and use it in GitHub Desktop.
docker tricks
# run a command inside a docker container
docker run --rm node ls
# run multiple commands inside a docker container
docker run --rm node bash -c "ls && pwd"
# pipe commands from stdin
echo "ls && pwd" | docker run --rm -i node bash
# pipe commands from script
cat myscript.sh | docker run --rm -i node bash
# do it with docker-compose (drop the "-i" since it will read from STDIN by default)
cat myscript.sh | docker-compose run --rm my-service bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment