Black Friday Deal : Up to 40% OFF! + 2 free self-paced courses + Free Ebook  - SCHEDULE CALL

- DevOps Blogs -

What is Docker? Docker Commands Cheat Sheet with Example for Ubuntu

Introduction

Docker is quite a popular and most used DevOps Tool worldwide. In this blog for Docker Commands Cheat Sheet, we will discuss Docker and its containers. We will also see the important Docker Commands that are used in Docker and why it is used by professionals. For this, you must know that Docker containers are usually used as a replacement for Virtual Machines. Following are the few reasons why to use DevOps Docker instead of a virtual machine for any software project:

  • Virtual machines take much time to boot. Containers take less time for booting because they use host OS and share the relevant libraries
  • Unlike virtual machines, they do not block host resources.
  • Containers have isolated libraries and binaries for their running applications.
  • Containers are handled by a separate engine that is called a containerization engine.
  • Docker gives a platform for containerization through which containers can be created and run.

It is clear from the discussion that Docker provides a platform for containers that are usually preferred over virtual machines. So now it’s time to introduce Docker in detail.

What is Docker? A quick introduction to Beginners

As far as Docker is concerned, Docker is a platform for containerization that can package a user application and its dependencies so that application works seamlessly in an entirely different environment.

Docker works on the concept of containers, containers are standard units that can be created to deploy any particular application for any environment. Docker can provide Ubuntu containers or CentOS containers as per the requirements that can work like an operating system. Developers may also get application-oriented containers like Tomcat-Ubuntu containers or CakePHP containers, etc.

DevOps Training & Certification Course

  • No cost for a Demo Class
  • Industry Expert as your Trainer
  • Available as per your schedule
  • Customer Support Available

What are the Features or Benefits?

Docker can be used by system administrators and developers so this is taken as an important part of DevOps. Docker has made the application deployment convenient and quick. Even application deployment flexibility has been increased due to Docker. It is comparatively a smaller tool so little overhead is required. Docker provides the following listed features to the users due to which it is a most preferred tool for the developers and administrators:

1). Shared Operating System

Docker containers do not need to set up their own separate operating system and they can use the existing OS features and storage so they do not require any separate operating system for execution. They are considered much more efficient than virtual machines because they use shared operating systems. Even rest OS can be used by other applications and they use only a part of that.

2). CI/CD

CICD or continuous integration and continuous deployment are two of the most in-demand and imperative features of Dockers. Here, the user needs not to wait for deployment after development, instead as soon as the application is developed and ready to use it can be deployed in a prototype environment and it can be tested as well.

3). Increased Portability

Through Docker, applications can get instant portability. Here, portability is easier so the application can be packed, shipped, and run instantly by a container. These containers are self-sufficient and can be made run from anywhere. So, in this way, application deployment and development become much easier when compared traditionally.

4). Isolated Code

Developers can isolate their application code through containers. As the code is kept in an isolated manner so whenever required, it can be changed or updated easily. Docker’s containers can be deployed on the cloud quickly and even larger applications can be broken down into smaller applications and then can be deployed as per requirements.

Read: Top 7 DevOps Tools: Manage & Optimize The Organizational Task

Comparison of Docker Containers and Virtual Machines

Usually, Docker containers are preferred over virtual machines. They both are compared to the following parameters:

  • Size - Through size, Docker containers and virtual machines are compared as per the number and size of resource that they need for execution.
  • Startup - Startup means a type of booting required. Virtual machines take much time to boot. Containers take less time for booting because they use host OS and share the relevant libraries
  • Integration- It signifies the capability of their integration with other tools in a seamless development environment.

Docker gives a better platform to build apps and microservices. As apps can be deployed automatically through the container, virtualization is provided in an efficient way. The user need not bear any extra cost for virtual machine implementation and so containers are considered an affordable and cost-efficient along with quickness. The development and testing phase of the application becomes easier and the user can easily execute the commands needed to deploy the application.

In the following situations, Dockers may be usually needed by the developers:

  • When you have to run your code locally on your laptop and need a duplicate running environment on the server-side.
  • For CI/CD during development, testing and QA process.
  • To distribute the OS of apps with a team and to control the version of an application.

In the above-mentioned cases, Docker can be of great help. The user can download the Docker edition and toolbox from the site to use it. For Oracle virtual box, you may need to install an additional pack and will have to then run the setup.

How can we use Dockers?

Virtual machines can create snapshots that can be revisited if required instantly. Docker containers enhance the virtualization of lightweight processes to become OS independent and to use Linux Kernel’s functionality. Through Docker image, these snapshots are being created, these images are in-turn created by Docker files that are customizable. Driver ‘libcontainer’ is used to create the default docker container. There is a Docker hub that can be used to search the images or to see the snapshots of the applications that are being created.

Most Used Commands of Docker or Docker Cheat Sheet with examples

So far in this blog, we have seen what Docker is and why is it being used. Now, in order to use Docker, you will have to execute certain commands. These commands are called Docker commands that are frequently used for the Docker platform.

Here is the list of these most used Docker commands for Ubuntu:

Docker Commands Cheat Sheet

docker –version docker kill
docker pull docker commit
docker run docker login
docker ps docker push
docker ps –a docker images
docker exec docker rm
docker stop docker build

Docker Cheat Sheet is a document that provides the information of basic Docker commands and their details with examples. When you install Docker, you can check the document to get information on each and every command used in Docker. Now let’s see the description of the above-mentioned commands along with some additional commands and examples that are frequently used in Docker:

DevOps Training & Certification Course

Read: What is Nagios? Nagios Configure & Install Tutorial Guide for Beginner
  • Personalized Free Consultation
  • Access to Our Learning Management System
  • Access to Our Course Curriculum
  • Be a Part of Our Free Demo Class

Docker – version

You can check the currently used Docker version on your system through this command -


$ docker –version

Docker pull

This command can pull the images from docker’s hub or repository that is hub.docker.com


$ docker pull ubuntu

All the images of the hub will be cached and stored from the docker’s hub.

Docker run

You can create a container from the image through this command.


$ docker run –it –d ubuntu

Docker ps

To check the running containers or to know how many containers are running right now, you can use this command:


$ docker ps

Docker ps –a

To view all the running and exited containers, you can use this command:


$ docker ps –a

Docker exec

To access the running container, you can use this command:


$ docker exec it <container id> bash

Docker stop

To stop the running container, we can use this command:


$ docker stop <container id>

Docker kill

The containers get killed after getting stopped by this command. In Docker, stop command container gets the full time to shut down, but when you need to shut down any container immediately then you can kill the Docker container through kill command.


$ docker kill <container id>

Docker commit

To create a new image of the edited container on the local system, you can use this command:

Read: A Starter Guide to Jenkins Cheat Sheet you Need to Know

$ docker commit <container id> <username/imagename>

Docker login

To login the docker hub repository, you can use this command:


$ docker login

Docker push

You can push a new image into Docker hub through this command:


$ docker push <username/image name>

Docker images

All locally stored images in docker hub will be listed through this command:


$ docker images

Docker rm

If you want to delete any stopped container then this command can help you:


$ docker rm <container id>

Docker build

If you want to build an image from a Docker file then you can use this command:


$ docker build <path to docker file>

Apart from the above-listed Docker commands cheat sheet, one can also use other commands for Docker like ‘docker export’ command that can export a container’s file system as an archive file or ‘docker attach’ that can attach any running container, etc.

Summary

There are many more Docker commands and it can be used as a container as well. You can check the Docker cheat sheet file to know the details of all commands that you can use in order to use the containers effectively. All Docker commands for Ubuntu can be executed with lots of options that we have already discussed throughout the blog.

You can use these commands for different objectives and don’t forget to share your experience with us how this blog helped you in using Docker commands cheat sheet successfully.



fbicons FaceBook twitterTwitter lingedinLinkedIn pinterest Pinterest emailEmail

     Logo

    JanBask Training

    A dynamic, highly professional, and a global online training course provider committed to propelling the next generation of technology learners with a whole new way of training experience.


  • fb-15
  • twitter-15
  • linkedin-15

Comments

Trending Courses

Cyber Security Course

Cyber Security

  • Introduction to cybersecurity
  • Cryptography and Secure Communication 
  • Cloud Computing Architectural Framework
  • Security Architectures and Models
Cyber Security Course

Upcoming Class

-1 day 22 Nov 2024

QA Course

QA

  • Introduction and Software Testing
  • Software Test Life Cycle
  • Automation Testing and API Testing
  • Selenium framework development using Testing
QA Course

Upcoming Class

0 day 23 Nov 2024

Salesforce Course

Salesforce

  • Salesforce Configuration Introduction
  • Security & Automation Process
  • Sales & Service Cloud
  • Apex Programming, SOQL & SOSL
Salesforce Course

Upcoming Class

-1 day 22 Nov 2024

Business Analyst Course

Business Analyst

  • BA & Stakeholders Overview
  • BPMN, Requirement Elicitation
  • BA Tools & Design Documents
  • Enterprise Analysis, Agile & Scrum
Business Analyst Course

Upcoming Class

-1 day 22 Nov 2024

MS SQL Server Course

MS SQL Server

  • Introduction & Database Query
  • Programming, Indexes & System Functions
  • SSIS Package Development Procedures
  • SSRS Report Design
MS SQL Server Course

Upcoming Class

0 day 23 Nov 2024

Data Science Course

Data Science

  • Data Science Introduction
  • Hadoop and Spark Overview
  • Python & Intro to R Programming
  • Machine Learning
Data Science Course

Upcoming Class

-1 day 22 Nov 2024

DevOps Course

DevOps

  • Intro to DevOps
  • GIT and Maven
  • Jenkins & Ansible
  • Docker and Cloud Computing
DevOps Course

Upcoming Class

4 days 27 Nov 2024

Hadoop Course

Hadoop

  • Architecture, HDFS & MapReduce
  • Unix Shell & Apache Pig Installation
  • HIVE Installation & User-Defined Functions
  • SQOOP & Hbase Installation
Hadoop Course

Upcoming Class

-1 day 22 Nov 2024

Python Course

Python

  • Features of Python
  • Python Editors and IDEs
  • Data types and Variables
  • Python File Operation
Python Course

Upcoming Class

7 days 30 Nov 2024

Artificial Intelligence Course

Artificial Intelligence

  • Components of AI
  • Categories of Machine Learning
  • Recurrent Neural Networks
  • Recurrent Neural Networks
Artificial Intelligence Course

Upcoming Class

0 day 23 Nov 2024

Machine Learning Course

Machine Learning

  • Introduction to Machine Learning & Python
  • Machine Learning: Supervised Learning
  • Machine Learning: Unsupervised Learning
Machine Learning Course

Upcoming Class

34 days 27 Dec 2024

 Tableau Course

Tableau

  • Introduction to Tableau Desktop
  • Data Transformation Methods
  • Configuring tableau server
  • Integration with R & Hadoop
 Tableau Course

Upcoming Class

-1 day 22 Nov 2024

Search Posts

Reset

Receive Latest Materials and Offers on DevOps Course

Interviews