Instructor: 00:01 First, we're going to run a Docker container in a detached state. To do that, we'll just type docker run -d, and then the image ID of the Docker image that we want to spin a container off of. Now that we have that container running, we can grab the container ID.
00:17 Using that container ID, we can reenter that container, so that we can operate from within. To do that, we'll type the command docker exec -it, then the container ID, and then the command that we want to enter into that container with. By typing bash, we will start a Bash session within that container.
00:37 Now that we're in the container, we can use commands inside of it. For example, I'll list out all the files that are inside this Docker container. These files just represent a mock Node application.
00:48 When we want to exit out of that Docker container, we simply press control-P-Q, and we will exit that Docker container. That control is going to be control whether you're on a Windows, a Linux, or a Mac. On a Mac, you do not hit the command key. It is always control-P-Q.
01:06 Now, let's walk through each part of this command. The exec command is what you use to run a command against a Docker container. Specifying a container ID lets Docker know what container you want to run the command against.
01:21 The command that we want to run against it is bash. That says that we want to start a Bash session of that container. The two flags are really important to give us the terminal-like behavior that we see when we run docker exec -it.
-01:36 i says that we want access to the SD in stream, which means when I run a command against Bash, I want to see what's returned as a result. The gives us a pseudo TTY. What that basically means is that it's going to give you the driver that you need in order to have terminal-like behavior inside that Docker container.
01:56 docker exec -it, container ID, bash is a combination of commands and options that give us a terminal-like interface that we can interact with our Docker containers against.