Docker

Installation

curl -fsSL https://get.docker.com -o get-docker.sh | sh
sudo usermod -aG docker <username>

Checking the installation

docker version -> check for status of the server and client

docker info -> config values

docker -> Gives list of all commands available


Basics - Creating and using containers

Container vs VM

Image vs Containers

Image -> Binaries, Libraries, Source code the make up the application

Container -> Running instance of that image, Can have many container running off of same image

Basics of docker containers

docker container run --publish 80:80 nginx

docker container run --publish 80:80 --detach nginx : Runs the container in the background

docker container run --publish 80:80 --detach --name myserver nginx: Specify custom name

docker container ls: Lists all the running containers

docker container ls -a: Lists all the containers

Run vs Start

docker container run: Starts a new container

docker container start: Starts an existing stopped container

Checking logs

docker container logs <name>

Docker container commands list

Working of docker container run command

Other docker commands

docker search <name>: Search on docker hub for image docker images: List all local images

Inside the containers

docker container top <name>: Information about the processes running inside the container

docker container inspect <name>: Metadata about the container (JSON format)

docker container stats <name>: Performance stats about all containers

Getting a shell inside a container

docker container run -it

docker container start -ai <name>

Networking in docker

docker container run -p host:container: Publish a container's port(s) to the host

docker container port <name>: Get port details for the container

CLI network management

DNS