Basics
An overview of what it is and some useful commands

What is Docker?

Docker It is a software platform that was released on 20 March 2013. This platform allows you to create container processes, which are simply processes that have all the required dependencies packaged in itself. It doesn’t use the host system’s packages to run.

This allows one to run things in isolation and minimise dependency issues and package conflicts that occur when you develop software. Docker runs all these processes run on the linux kernel as root. It is present on other operating systems as well, but it is best suited for the linux kernel, in my opinion.

This concept isn’t new however, so what makes docker different, in my opinion is

For more information, I suggest you look into other blogs or youtube videos to get a better understanding.

Commands

Running

docker run <image name>
  1. This is a simple way of running an image to create a container. It will do something only if the docker image that you are pulling is made to do something when run like this (usually not the case)

  2. A more useful way of doing this would be something like

docker run -it -v $(PWD):/my_folder_in_container -w /my_folder_in_container --rm --name <customname> <image name>

This is a long command, let’s break it down and understand the arguments. More of them can be found here if you want a better explanation or other use cases.

Starting

docker start <customname>

This starts a docker container with the name <customname>.

Executing

docker exec -it <customname> bash

Killing

docker kill <customname>

This kills a running container of the name <customname>

Pulling

docker pull <image name>

This command pulls the docker image <image name>

Information About Containers

docker ps

This shows all running containers

docker ps -a

With Dockerhub

docker login

Lets you login to your dockerhub account from where you can push, pull containers and images in your account, among other things.

docker commit <customname> <new_image_name>:latest

Once you have logged in, this command allows you to commit all changes to the container <customname> and save it to an image named <new_image_name> with a tag latest, to the user smellingsalt.

docker push smellingsalt/<new_image_name>:latest

This will push the docker image smellingsalt/<new_image_name> to the dockerhub account smellingsalt with a tag latest

Others

After installing Docker, to prevent having to always type sudo before every command, run the following to add the current user in a created user group.

sudo usermod -aG docker $USER
# apply changes to current shell (or logout/reboot)
$ newgrp docker

With Dockerfiles

Will be updated soon!