Working with Docker Containers
In this chapter, we will cover the following recipes:
- Listing/searching for an image
- Pulling an image
- Listing images
- Starting a container
- Listing containers
- Looking at the container logs
- Stopping a container
- Removing a container
- Removing all stopped containers
- Setting the restart policy on a container
- Getting privileged access inside a container
- Accessing the host device inside a container
- Injecting a new process into a running container
- Reading a container's metadata
- Labeling and filtering containers
- Reaping a zombie inside a container
Introduction
In the previous chapter, after installing Docker, we pulled an image and created a container from it. Docker's primary objective is running containers. In this chapter, we'll see the different operations we can perform with containers, such as starting, stopping, listing, deleting, and so on. This will help us use Docker for different use cases, such as testing, CI/CD, setting up PaaS, and so on, which we'll cover in later chapters. Before we start, let's verify the Docker installation by running the following command:
$ docker version
This will give the Docker client and server version, as well as other details.