Skip to content

Instantly share code, notes, and snippets.

@acidDrain
Created August 26, 2021 01:41
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 acidDrain/64cdf92cc090d3466b78418e8cc17d60 to your computer and use it in GitHub Desktop.
Save acidDrain/64cdf92cc090d3466b78418e8cc17d60 to your computer and use it in GitHub Desktop.
Example of how to pipe output into a container
# This is how piping a file into a container could be done for a build.
# The container’s ID will be printed after the build is done and the build logs
# could be retrieved using docker logs. This is useful if you need to pipe a
# file or something else into a container and retrieve the container’s ID once
# the container has finished running.
#
# See https://docs.docker.com/engine/reference/commandline/run/#attach-to-stdinstdoutstderr--a

$ date | docker run -i -a stdin debian:buster sh -c 'printf "%s\\n" "Hello world $@" && cat -'
a81c825a2a1a5aad420fbda2fd74fa38e20eb7483bb3a48fec05280705ec99b7
$ docker logs a81
Hello world
Wed Aug 25 08:36:04 PM CDT 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment