DEV Community

Cover image for Understanding Docker
Nancy Rike
Nancy Rike

Posted on • Edited on

Understanding Docker

Many a time, docker is seen as a very difficult and techy area of web development. But it is not entirely so. My plan for the next few minutes of this read is to convince you otherwise.

Now what is Docker?
Docker is a popular and major platform or toolkit used to build, manage, deploy and ship systems. the docker engines allows us to run and distribute applications easily.

Now so far we have heard some keywords and may be wondering what they mean other than their regular pedestrian meaning words such as containers, images, virtual machines and so on.

Containers: A docker container is a lightweight, standard, and secure environment that allows one to ship their applications, and run it in an isolated part of the operating system (OS). They are instances of docker images that run the actual application. Containers allow for speedy and reliable packaging of code and its dependencies. It is important to note that whatever is written in a container, stays in the container.

Virtual Machine: VM as the name implies a virtual machine is a full system that can be run locally in another computer for example simulators, emulators, parallel machines e.t.c VMs allow a computer run on a host machine.

Containerization is the process of packaging an app and all its dependency into an easy to use container image.

A docker Image is a blueprint of an application, which forms the basis of a container. docker images includes the app and all the app dependencies which

How to get started
First thing you need to do is to install docker you can choose to do this from the official docker website, then follow the installation steps. you can also download it by running sudo apt-get install docker.io when this is done, confirm the installation by running

docker --version or docker -v
to ascertain the version of installed docker.

The following commands are very important to run docker

  1. Docker pull [image name]: this command is used to download a docker image from docker hub e.g
docker pull python
Enter fullscreen mode Exit fullscreen mode
  1. docker run [image name]: this command is used to start a container from an image.
  2. docker ps -a : this command will give a list of all containers including those that have been stoped.
  3. docker ps: this command returns a list of all running containers.
  4. docker stop [container id] : use this command to stop a container to restart the container use the command:
  5. docker start: this command is used to start a container. docker build: docker build is used to create a docker image
  6. docker rm: is used to remove a stopped container
  7. docker images: this command gives a list of all docker images in the system.
  8. docker rmi [image id / image name]: allows you to remove a specific image
  9. docker run -d : this command is used to run a new detached container. (a detached container runs on the background, independent of the teminal. That way it doesn’t stop running when the terminal is closed)

Do you have questions or contributions? be sure to leave them in the comment section below.
xoxo
Nancy Rike

Top comments (0)