Docker User Guide – Quick Reference

Are you finding difficulty in remembering all the commands that you need in order to work with Docker?
Guys don’t worry if you are a beginner and have no idea about how Docker works, this Docker cheat sheet will give you a quick reference of the basics that you must know to get started.
Prepare yourself for the Top DevOps Interview Questions And Answers!

Watch this Docker Tutorial for Beginners video

Docker Cheat Sheet Docker User Guide - Quick Reference Are you finding difficulty in remembering all the commands that you need in order to work with Docker? Guys don’t worry if you are a beginner and have no idea about how Docker works, this Docker cheat sheet will give you a quick reference


While at Intellipaat, we support our learners with a handy reference, that’s the reason we have created this Cheat sheet. This cheat sheet is designed for the one who has already started learning about Docker but needs a handy reference sheet.
Download a Printable PDF of this Cheat Sheet
docker cheat sheet

Introduction

Docker tool was introduced in order to make it easier for you to create, deploy, and run applications by using containers. Containers provision you the packaging of your application with all the important components it requires, like libraries and other dependencies, and ship them all out as one package. Due to which you as a developer can be assured that your application will run on any other machine.
Become Master of DevOps by going through this online DevOps training in London.

Architecture

We will start from understanding Docker’s Architecture and main aspects in it, then we will continue with the important commands required for docker installation, build, push, run, ship etc. operations.
DevOps architecture consists of these 5 main entities which are Registry, Images, Containers, Docker Daemon and Client.

  • Registry: It hosts the public and official images, docker registry that we use is Dockerhub.
  • Images: It can be downloaded from the registry directly or implicitly when starting a container.
  • Containers: They are basically instances of the images, multiple containers for a single image is possible.
  • Docker daemon: Daemon creates, runs and monitors the containers along with building and storing the images.
  • Client: Client talks to daemon via http.

Go through the Best DevOps Course in New York to get clear understanding of DevOps.

Orchestrate

Orchestration is used for managing the container’s lifecycle especially in dynamic environments.
It is used for controlling and automating many tasks for the container. There are many Docker Orchestration tools like Docker Swarm, Kubernetes etc, and we’re using Docker Swarm commands below, let’s check the commands used for Docker Orchestration.
Learn more about DevOps in this DevOps training in Sydney to get ahead in your career!
Commands:

  • To initialize swarm mode and listen to a specific interface.
    • Docker swarm init --advertise-addr 10.1.0.2
  • Join an existing swarm as manager node
    • Docker swarm join --token<manager-token> 10.1.0.2:2377
  • Join a swarm as a worker node
    • Docker swarm join --token<worker-token> 10.1.0.2:2377
  • List all the nodes in the swarm
    • Docker node ls
  • Create a service from an image on the existing port and deploy 3 instances
    • Docker service create --replicas 3 -p 80:80 name -webngix
  • List services running in swarm
    • Docker service ls
  • Scale a service
    • Docker service scale web=5
  • List tasks of a service
    • Docker service ps web

Watch this interesting video on DevOps Training

Docker Cheat Sheet Docker User Guide - Quick Reference Are you finding difficulty in remembering all the commands that you need in order to work with Docker? Guys don’t worry if you are a beginner and have no idea about how Docker works, this Docker cheat sheet will give you a quick reference

Build

Build command is used for building images from a docker file. Let’s check some of essential docker build commands.
Commands:

  • To build the image from the docker file and tag image
    • Docker build -t myapp :1.0
  • List all images that are locally stored
    • Docker images
  • Delete an image from the docker store
    • Docker rmi alpine: 3.4

If you have any doubts or Queries related to DevOps, get it clarifies from DevOps Experts on DevOps Community.

Run

Run command is used for creating a container from a specified image. Check these run commands for your reference.
Commands:

  • To create and run a command:
    • Docker run –name container_name docker_image
  • Flags used:
    • -d detach container on start
    • -rm remove container once it stops
    • -p publish host ip and host port to the container por
    • -v define and share volume across containers
    • –read-only sets it to read only permission

Ship

Docker gives you the capability of shipping your application container anywhere, on any platform, let’s check some commands for it.
Commands:

  • To pull an image from the registry
    • Docker pull alpine:3.4.
  • Retag a local image with a new image name
    • Docker tag alpine:3.4 myrepo/ myalpine:3.4
  • Log in to a registry
    • Docker login my.registry.com:8000
  • Push an image to a registry
    • Docker push myrepo/ myalpine:3.4

Interested in becoming DevOps Expert? Click here to learn more in this DevOps Course in Toronto!

Watch this interesting video on ‘Who Is a DevOps Engineer?’:

Docker Cheat Sheet Docker User Guide - Quick Reference Are you finding difficulty in remembering all the commands that you need in order to work with Docker? Guys don’t worry if you are a beginner and have no idea about how Docker works, this Docker cheat sheet will give you a quick reference

Clean up

To prevent from wasting the resources, you must know how to clean, we are providing few essential commands for same.
Commands:

  • To clean unused/dangling images:
    • Docker image prune
  • To remove images not used in containers
    • Docker image prune -a
  • To prune the entire system
    • Docker system prune
  • To leave a swarm
    • Docker swarm leave
  • To remove a swarm
    • Docker stack rm stack_name
  • To kill all running containers
    • Docker kill $ (docker ps -q)
  • To delete all stopped containers
    • docker rm $(docker ps -a -q)
  • To delete all images
    • docker rmi $(docker images -q)

Services

Let’s take a sneak peek over the commands used for viewing the running services, run the services, to view all service logs and to scale the services.
Commands:

  • List of all services running in a swarm
    • Docker service ls
  • To see all running services
    • Docker stack services stack_name
  • To see all service logs
    • Docker service logs stack_name service_names
  • To scale service across qualified nodes
    • Docker service scale stack_name_service_name= replicas

Interested in getting an industry-recognized certification in DevOps? Enroll in Intellipaat’s DevOps Course in Bangalore now!

Watch this Docker Video

Docker Cheat Sheet Docker User Guide - Quick Reference Are you finding difficulty in remembering all the commands that you need in order to work with Docker? Guys don’t worry if you are a beginner and have no idea about how Docker works, this Docker cheat sheet will give you a quick reference

Interaction with a container

Let’s check how to make an interaction with a container

  • Run a command in the container
    • Docker exe -ti container_name command.sh
  • Follow the container logs
    • Docker logs -ft container name
  • Save a running container as an image
    • Docker commit -m “commit message” -a “author” container_name username/image_name: tag

Now, you know the most important skill set of a DevOps Engineer. But, do you know, DevOps Engineers are among the highest paid professionals in the technology domain? so join DevOps training in Hyderabad!

Watch this video on DevOps Tutorial for Beginners

Docker Cheat Sheet Docker User Guide - Quick Reference Are you finding difficulty in remembering all the commands that you need in order to work with Docker? Guys don’t worry if you are a beginner and have no idea about how Docker works, this Docker cheat sheet will give you a quick reference

Important terms

Some of the important terms while using docker container.

  • Layer: Read-only files to provision the system
  • Image: Read only layer that is the base of the image
  • Container: A runnable instance of the image
  • Registry/hub: Central place where images live
  • Docker machine: A VM to run docker containers
  • Docker compose: A VM to run multiple containers as a system.

Download a Printable PDF of this Cheat Sheet
We have covered all the basics of Docker in this cheat sheet. If you want to start learning DevOps in depth then check out the DevOps Certification by Intellipaat.
Not only will you get to learn and implement Docker with a step by step guidance and support from us, but you will also get to learn other important topics in DevOps such as Chef, Git/GitHub, Ansible, Jenkins, Puppet, Selenium, Nagios and many more. You will also get 24*7 technical support to help you with any and all of your queries, from the experts in the respective technologies here at intellipaat throughout the certification period. So, why wait? Check out the training program and enroll today!
Get in touch with Intellipaat for a comprehensive DevOps Training and be a certified DevOps Engineer!

Leave a Reply

Your email address will not be published. Required fields are marked *