docker container

Docker Container

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 Container

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
docker container
‘Docker help’ is a great way of seeing a list of all the available options.

docker search
docker container
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

docker pull
docker container
‘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.

docker images
docker 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
docker container
‘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
docker container
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.

docker rm
docker container
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>

docker rmi
docker container
For a given image if there are no container instances, you can remove the image by typing in ‘docker rmi ‘. This will remove the image from your machine.

Conclusion

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.

Mo

I am a passionate tester, father, husband and gamer. I love to upload videos on my YouTube channel, write blogs about Software Testing and generally contribute back to the Software Testing world.

More Posts - Twitter - Facebook - Google Plus

Published by

Mo

I am a passionate tester, father, husband and gamer. I love to upload videos on my YouTube channel, write blogs about Software Testing and generally contribute back to the Software Testing world.

One thought on “Docker Container”

Leave a Reply