Docker Installation and commands

Sagar Kulkarni
2 min readApr 25, 2024

--

As we know with Docker being part of our daily development work, it is no wonder that more and more people install it on their computers. In this tutorial, we will take a look at installing Docker on Windows 10 or Windows 11. and Linux — Ubuntu

Install Docker Desktop on Windows

Installation on Ubuntu

sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt-cache policy docker-ce
sudo apt install docker-ce
docker --version

Basic Commands

docker version
docker info #This command displays various information about the Docker installation, such as the number of containers, images, and volumes currently running,
docker daemon -v #he version of the Docker daemon that is currently running.
docker images #lists all the Docker images available on the host.
docker pull nginx:latest #This command pulls a Docker image from a registry, such as Docker Hub. For example, if you want to pull the latest version of the "nginx" image, you might run:
docker run --name my-nginx-container -p 8080:80 -d nginx:latest
#Explain :1] docker run is used to run a container from image
2] --name my-nginx-container name of container
3] -p 8080:80 This option maps port 8080 on your host machine to port 80 inside the container.
4] -d run a container in detached mode, meaning it runs in the background
5] nginx:latest specifies the image you want to use to create the containe

docker run --name my-co -p 8081:80 -d httpd
docker ps # lists all the running containers.
docker ps -all #lists all containers including the ones that have exited
docker stop <container ID or name> #stop the container
docker exec -it <Container_ID> /bin/bash #go inside the container
docker rm <container ID or name> #remove container
docker rmi <Image_id or name> #delete the image
docker logs <container ID>
docker exec
docker prune

--

--