Skip to main content

Docker Commands

Exec and Attach

0:00
LearnStep 1/2

Exec and Attach

Exec and Attach

docker exec

Run a command in a running container:

bash

docker attach

Attach to container's main process (PID 1):

bash

Difference: exec vs attach

execattach
Creates new processConnects to main process
Multiple sessions possibleSingle session to PID 1
Exit doesn't stop containerExit may stop container
Use for debuggingUse for interactive apps

Copying Files

bash