Difficulty: Beginner
Estimated Time: 10 minutes

In this lab, we will learn about attaching and detaching to a container's STDOUT

Attach and Detach


  • Run Centos image in detached mode:
    docker container run -d centos ping -c 50

  • Attach to the newly created container and observe the output:
    docker container attach $(docker container ls -q)
    exit using CTRL+C.

  • Check your running containers and notice that your container is no longer running:
    docker container ls
    The CTRL+C combination killed the container process.

  • Run another container, but this time with -it passed:
    docker container run -d -it centos ping -c 50

  • Attach and detach from container:
    docker container attach $(docker container ls -q)
    ^P^Q NOTE: This will not work in katacoda, CTRL-Q maps to quit.

  1. Show your container still running in the background:
    docker container ls
This tab will not be visible to users and provides only information to help authors when creating content.

Creating Katacoda Scenarios

Thanks for creating Katacoda scenarios. This tab is designed to help you as an author have quick access the information you need when creating scenarios.

Here are some useful links to get you started.

Running Katacoda Workshops

If you are planning to use Katacoda for workshops, please contact [email protected] to arrange capacity.

Debugging Scenarios

Below is the response from any background scripts run or files uploaded. This stream can aid debugging scenarios.

If you still need assistance, please contact [email protected]