attach.rst 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. :title: Attach Command
  2. :description: Attach to a running container
  3. :keywords: attach, container, docker, documentation
  4. ===========================================
  5. ``attach`` -- Attach to a running container
  6. ===========================================
  7. ::
  8. Usage: docker attach CONTAINER
  9. Attach to a running container.
  10. You can detach from the container again (and leave it running) with
  11. ``CTRL-c`` (for a quiet exit) or ``CTRL-\`` to get a stacktrace of
  12. the Docker client when it quits.
  13. To stop a container, use ``docker stop``
  14. To kill the container, use ``docker kill``
  15. Examples:
  16. ---------
  17. .. code-block:: bash
  18. $ ID=$(sudo docker run -d ubuntu /usr/bin/top -b)
  19. $ sudo docker attach $ID
  20. top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
  21. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  22. Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  23. Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
  24. Swap: 786428k total, 0k used, 786428k free, 221740k cached
  25. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  26. 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
  27. top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
  28. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  29. Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  30. Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
  31. Swap: 786428k total, 0k used, 786428k free, 221776k cached
  32. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  33. 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
  34. top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
  35. Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
  36. Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
  37. Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
  38. Swap: 786428k total, 0k used, 786428k free, 221776k cached
  39. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
  40. 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
  41. ^C$
  42. $ sudo docker stop $ID