What is Docker?
Software development is a lengthy, cumbersome, and a process of complex stages. The stages can be divided from the problem to the software idea (solution of the problem) to design of the software to the software development to the deployment of the software. Docker, being a container, makes software deployment error-prone to error-free. This blog is aimed to learn necessary docker commands in one place.
What is a container and what problems does it solve?
As the name suggests, a container is a bunch of things. But which things does it include? Answer to that, dependencies and necessary configuration. Saying briefly, Container technology is a way to package application with all the necessary dependencies and configuration. Moreover, it is a portable artifact, and a person can easily share and transfer it to another place after packaging it in one isolated environment. This is important to transfer information and packages quickly from development team to operations team to testing team as well.
Pre-requisites to execute following Docker Commands:
- A supported version of macOS
- At least 4 GB of RAM
- Install Docker Desktop in Mac
- Download the installer from Docker Official Website.
- Click on Docker.dmg, and move the Docker icon to Applications folder
- Start Docker by clicking Docker.app
- For more Information, Go to Docker Official Website.
Basic Docker Commands:

1. Pull Docker Image from Docker hub (Line 1), Pull docker image using specific version (Line 2), To check pulled images on device (Line 3)
docker pull redis ("redis" is a image from Docker)
docker pull redis:1.2 ("docker image":Version)
docker images
2. (Line 1) Create a new container in which application image is running. If there is no application image in the machine, then it is downloaded and then a container is created by executing this command. (Line 2) This command executes and runs a container in a detached mode. (Line 3) This command assigns dedicated port to communicate with application, where -p 6000:6379 correlates to -p machine port : container port. (Line 4) This command displays the list of running containers on the machine. (Line 5) This command starts the container. (Line 6) This command stops the container.
docker run redis
docker run -d redis:1.2
docker run -p 6000:6379
docker ps
docker start (Container_Id/Container_name)
docker stop (Container_Id/Container_name)
docker run -d -p6000:6379 --name redis_newer redis
3. Remove Docker Image. (Line 1) To look into the list of containers that are running. (Line 2) To look into the history of containers that are either started or stopped. (Line 3) Remove the container (Line 4) Remove the image.
docker ps
docker ps -a
docker rm (Container_Id/Container_name)
docker image rm (image_name)
4. Debug Container. (Line 1) To go into a file system of running container. You can then use basic Linux Commands such as ls, pwd, env, cd/ etc.
docker logs (Container_Id/Container_Name)
docker exec -it (Container_Id/Container_Name) /bin/bash