Working with an interactive container

In the first chapter, we ran our first Hello World container to get a feel for how the containerization technology works. In this section, we are going to run a container in interactive mode. The docker run subcommand takes an image as an input and launches it as a container. You have to pass the -t and -i flags to the docker run subcommand in order to make the container interactive. The -i flag is the key driver, which makes the container interactive by grabbing the standard input (STDIN) of the container. The -t flag allocates a pseudo-TTY or a pseudo Terminal (Terminal emulator) and then assigns that to the container.

In the following example, we are going to launch an interactive container using the ...

Get Learning Docker - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.