DEV Community

Cover image for Docker for Beginner's
Ragu
Ragu

Posted on

Docker for Beginner's

Source from Zeal Vora,KPLABS Course(Premium Instructor at Udemy)
Udemy

Zeal is one of my favorite author for docker. Please try to yourself 💖

(Tip: HE is ready to give some discount for students 😜)

-----------------Table of content-----------------

  1. What is docker and why we need ?

  2. Docker Installation and pre-requisite

  3. Image VS. Containers

  4. Basic commands

  5. port binding

  6. Attached and detached mode

  7. Restart policy

  8. Disk usage


1.Container and purpose

Docker is the set of alone process and container tool. Its easy to deploy the microservice with running application using the containers.

  • Weightless
  • Movable
  • Compact

2. Docker Installation and pre-requisite

Docker available in variety of operating systems, this includes:

  • Windows
  • Linux
  • MAC

The installation of Docker is pretty straight forward in each one of them.

Docker installation

3. Image VS. Containers

Microservice application (Recipe of microservice) procedural code is called image

container

Running docker image is called container.

container

4. Basic commands

docker images - List the docker images

docker pull image-name i Pull the image from docker hub
docker ps - List the container
docker stop container-ID - Stop the container
docker start container-ID - Start the container
docker rm -f image name - Remove the docker image
netstat -ntlp - See the running port
docker exec -it container-id /bin/bash - Goto inside the container
docker run -dt -p containerport:actualport --name=anyname conatainer id - Port mapping with container

docker container stop $(docker container ls -aq) - Stop the all container

docker container rm $(docker container ls -aq) - Remove the all container

5. port binding

Goto inside the container

docker exec -it container-id /bin/bash

Port mapping with container

Image description
docker run -dt -p 80:81 --name=anyname conatainer id

6. Attached and detached mode

docker run -dt

d - detached mode
t - terminal tty

When we start a docker container, we need to decide if we want to run in a default foreground mode or the detached mode.

You may want to use this if you want a container to run but do not want to view and follow all its output

7. Restart policy

when docker daemon is stopped that time entire container goes
down. we avoid that situation so we using the restart policy

  • no - Do not automatically restart the container
  • on-failure - Restart the container if its exists due to an error
  • unless-stopped - Restart the container unless it is explicitly stopped
  • always - Always restart the container if it stops

8. Disk usage

docker system df

container

Top comments (1)

Collapse
 
bobbyiliev profile image
Bobby Iliev

Well done!

I could also suggest this free eBook here:

github.com/bobbyiliev/introduction...