A Docker Container is an encapsulated solution for running a machine with applications/software. It internalizes all dependencies allowing anyone to run a container on any machine, any cloud etc therefore making the process much more easier.
First of all, consider quickly going through ‘Installing Docker in Windows’ before continuing with this post.
Docker has many commands which can be used to manage containers. Some of these are:
docker --help docker search <image> docker pull <image> docker images docker run <image> docker ps -a docker rm <containerID> docker rmi <image>
‘Docker help’ is a great way of seeing a list of all the available options.
The ‘search’ command can be used to locate an image in the Docker Hub. This can be useful when trying to find a specific image to either pull or run.
Docker Image Management
‘Pull’ is used to create an exact copy of an image from the Docker Hub in your local machine. In other words, ‘docker pull’ is used to copy the image to a hard drive. This gives the option to run the image on a machine as a container.
After an image has been pulled, it is possible to see a list of all the local images. ‘docker images’ can be used to see a list of all the images currently on a machine.
‘docker run’ can be supplied with the name of an image. This effectively tries to run the image as a container on a Docker instance.
You can supply more parameters with ‘docker run’ command, for instance:
docker run -it ubuntu bash
This will run an Ubuntu image as a container, giving control over the terminal in Ubuntu.
docker ps -a
Have you ever wondered how you can see a list of all the current containers on your machine? Well, try typing in ‘docker ps -a’, this will return all the current containers on your machine.
It is possible to remove a container by supplying the container ID with ‘docker rm’. If the container is still running when trying to remove, you will have to stop it first. You can stop a container by:
docker rm <containerID>
For a given image if there are no container instances, you can remove the image by typing in ‘docker rmi
Docker has a number of commands. These commands can be used to search for an image, to pull the image and to ultimately deploy an image. This gives a Docker user the control to manage an image and to turn it into a container.