Skip to content

Instantly share code, notes, and snippets.

@rimelek
Created August 9, 2019 19:53
Show Gist options
  • Save rimelek/38f261fe9ffb409327c0e2ab4003b97e to your computer and use it in GitHub Desktop.
Save rimelek/38f261fe9ffb409327c0e2ab4003b97e to your computer and use it in GitHub Desktop.
Test attaching to a docker container's standard input
FROM ubuntu
CMD bash -c 'echo -n "Type your name: " && read name && echo -n "Your name is " && echo $name && sleep 4'
# Test commands:
# docker build -t attachtest .
# docker run -d -it --name attachtest-container attachtest
# docker attach attachtest-container
# docker rm -f attachtest-container
# # Output should be the name you typed
# # Now remove the test container
# docker rm -f attachtest-container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment