how to send a single command via docker attach and exit with crtl+p and crtl+q

Viewed 47

How can I do the following via script?

  • run the command: docker attach my_container
  • enter to the existing TTY: enable backup
  • detach again with crtl+p ctrl+q
1 Answers

Just do docker exec:

docker exec my_container echo "hello, world!"

Documentation.

Related