Docker sq
Docker Fundamentals - Container Lifecycle
  •  

Detaching and Attaching

Mute
Current Time 0:00
/
Duration Time 0:00
Loaded: 0%
Progress: 0%
Stream TypeLIVE
Remaining Time -0:00
 
PRO

Detaching and Attaching

Start a container with a command like this one:

$ docker conatiner run --name c1 -it alpine:latest sh

where c1 is the name given to the new container and alpine:latest is the name and tag of the image you wish to use. You should see / # at the prompt, indicating that you are attached to the container.

-it allows you to easily detach the container later by pressing ctrl+p+ctrl+q. If you instead use -itd the container will initialize unattached.

You can re-attach to a running container by entering $ docker container attach [container name]

 

I finished! On to the next chapter