EDUCBA

EDUCBA

MENUMENU
  • Free Tutorials
  • Free Courses
  • Certification Courses
  • 360+ Courses All in One Bundle
  • Login

Docker Commands

By Anandkumar MurugesanAnandkumar Murugesan

Home » Software Development » Software Development Tutorials » Docker Tutorial » Docker Commands

Docker Commands

Introduction To Docker Commands

Docker implies OS-level virtualization. Most developer prefers using docker and operating systems are tightly coupled with developers. Optimizing on the platform’s functionality kicks with docker commands mastery. They are very much lightweight VM’.

Basic Commands

  • docker –version – Display the current version
  • docker pull <image> – Docker repository images can be pulled using docker pull command

Example:

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

docker pull ubuntu

  • docker run -it -d <image name> – For generating a container from an image

Example:

docker run -it -d ubuntu

  • docker ps -a – Displays running and exited containers
  • docker exec -it <container id> bash – Command for accessing running container
  • docker kill <container id> – Command for stopping the execution of a container immediately

Example:

docker kill d61153bc

  • docker commit <container id> <username/image name> – This command creates a new image of an edited container on the local system
  • docker push <username/image name> – This Docker command is used to push an image to docker hub repository
  • docker images – Listing all images stored in a docker
  • docker rm <container id> – Deleting a container which has stopped execution

Docker Intermediate Commands

  • docker checkpoint command – This Docker command used for managing checkpoints
  • docker save [OPTIONS] IMAGE [IMAGE…] – Saving more than one images to tar archives

Example:

docker save --output testbox.tar textbox

  • docker search [OPTIONS] TERM – Searching docker hub for images

Example:

docker search textbox

  • docker stats [OPTIONS] [CONTAINER…] – Displaying resource usage statistics

Example:

docker stats

  • docker system command – It is Used for Managing a docker

Command

Description

docker system df Show docker disk usage
docker system events Get real-time events from the server
docker system info Display system-wide information
docker system prune Remove unused data
  • docker tag SOURCE_IMAGE[: TAG] TARGET_IMAGE[: TAG] – Creating a target image referring to a source image

Example:

docker tag 0e5574283393 fedora/httpd:version1.0

  • docker unpause CONTAINER [CONTAINER…] – Unpause all process within one or more containers

Example:

docker unpause test container

  • docker import [OPTIONS] file|URL|- [REPOSITORY[: TAG]] – Importing contents from tarball to create a system image of the file
  • docker info [OPTIONS] – Display system-wide information

Example:

docker info -f

  • docker logout [SERVER] – Logging out of a Docker registry

Advanced Commands

  • docker-machine upgrade default – To upgrade the docker to the latest version. How this upgrade happens depends on the underlying distribution used on the created instance.
  • docker build –rm=false – Boolean options take the form -d=false. The value you see in the help text is the default value which is set if you do not specify that flag. If you specify a Boolean flag without a value, this will set the flag to true, irrespective of the default value.

Trips and Tricks To Use Docker Commands

  • Use -f flag for activating the logging

Example:

docker logs <containerid> -f

  • JSON split can be achieved in docker by default, single keys can be extracted using jq.
  • Package installations have to be taken increased care as those commands are cached as well.
  • There are a few places where one can specify commands in your Docker file.
  • A cache will be invalidated by add when the files are changed
  • At the time of building the image, there is no use of writing to the volumes
  • All users are determined from the host hence there is no user namespacing docker.
  • Sudo helps to execute the commands
  • Starting a docker into execution is a comparatively easy process
  • Docker allows the creation of aliases for its own commands in a very effective manner. This helps to manage and handle long and really large commands. Files ~/.bashrcor ~/.bash_aliases holds the alias values.
  • For reaching out containers accessed internally on a network there is always a need to withhold the corresponding ID of the container, the command ps -a helps to get this archived.
  • When a needed port is occupied on a different service, then for executing a container the host port can be plugged into a specific container port.Eg(host port 8080 to container port 50)
  • Docker provides additional support to clean the unnecessary code bits from the deployment container.
  • Its always set to pair the docker file associated to its respective run statements. This helps to solve problems as prescribed excluding unnecessary disk space usage.
  • Docker always prefers catching up on statements in the docker file that has not faced any change. Time-saving can be achieved by setting the contents depicted in the docker file at an order where the least possible change contents are mentioned at the top and more likely change contents are depicted at the bottom of the file.

Conclusion

Though docker seems to be an easy setup it’s actually a complex system to handle when considering its vibrant features into a picture. Definitely, Docker is among the popular virtualization tools and allows extremely coupled with the host operating system.

Recommended Articles

This has been a guide to Docker Commands. Here we have discussed basic, immediate as well as advanced Docker Commands. You may also look at the following articles to learn more.

  1. Advanced GIT Commands
  2. List of Rails Commands
  3. Basic C Commands
  4. Bootstrap Commands

Docker Training (4 Courses)

4 Online Courses

3 Hands-on Projects

11+ Hours

Verifiable Certificate of Completion

Lifetime Access

Learn More

0 Shares
Share
Tweet
Share
Primary Sidebar
Docker Tutorial
  • Docker
    • What is Docker in Linux
    • Docker Architecture
    • Install Docker
    • Advantages of Docker
    • Docker Commands
    • Docker Toolbox
    • Docker Storage Drivers
    • Docker Push
    • Docker run Command
    • Dockerfile
    • Docker Containers
    • Docker Container Linking
    • Docker Stop Container
    • Docker List Containers
    • Docker Registry
    • Docker Volume
    • Docker Images
    • Docker Export
    • Docker Import
    • Docker Systemd
    • Docker Stack
    • Docker Privileged
    • Docker Pull
    • Docker ENTRYPOINT
    • Docker Start
    • Docker system prune
    • Docker Hosts
    • Docker Logging
    • Docker Save
    • Docker Commands Cheat Sheet
  • Docker Swarm
    • What is Docker Swarm
    • Docker Swarm Architecture
  • Interview Questions
    • Docker Interview Questions

Related Courses

Docker Training Course

Python Training Course

Software Development Course Training

Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Corporate Training
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

© 2020 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA Login

Forgot Password?

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you
Book Your One Instructor : One Learner Free Class

Let’s Get Started

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

*Please provide your correct email id. Login details for this Free course will be emailed to you

Special Offer - Docker Training (4 Courses) Learn More