11 Docker Commands: A Guide of Docker Commands with Examples [2023]

Docker – ‘A better way to build apps’, as stated on its website, is an open-source platform for building apps and microservices. The catch here is the automated deployment of your app in a container, by OS level virtualization provided by Dockers. Dockers are better than VMs as you can do away with the additional costs for maintaining and starting the latter. By deploying your app and its dependencies (i.e. the pre-requisite apps for its proper functioning) in a container, your app becomes portable during all the phases of development and testing. Moreover, the isolated apps eliminate conflicts, enable team collaboration, and reduce the time-to-market.

 

When Do You Need to Use a Docker?

  • For replicating the environment on your server, while running your code locally on your laptop
  • For Docker CI/CD during numerous development phases (dev/test/QA)
  • For distributing your app’s OS with a team, and as a version control system.

How Do You Setup a Docker Locally

  • Download a Docker edition and the Docker Toolbox
  • Make sure your BIOS has Virtualization Technologies, AMD-V, or KVM enabled
  • Install the Extension Pack in the Oracle VirtualBox.
  • Run the Setup

How Do You Use a Docker?

The biggest advantage of VMs is that they create snapshots which can be revisited instantly later. Docker containers further enhance the lightweight process virtualization by being OS-independent and using the Linux Kernel’s functionality. They are created from Docker images – like snapshots. Docker images are created using a Docker file which can be customized or used as is. The default execution driver for creating a docker container is ‘libcontainer’.  Docker Hub can be used for searching docker images and seeing the way they have been built.

  • To create a Docker container, download the ‘hello world’ image, by typing the following command in the terminal –

$ docker run the hello world

  • For checking the number of images on your system, use the following command –

$ docker images

  • For searching an image in the Docker Hub –

$ docker search <image>

Here’s a List of Docker Commands

  • docker run – Runs a command in a new container.
  • docker start – Starts one or more stopped containers
  • docker stop – Stops one or more running containers
  • docker build – Builds an image from a Docker file
  • docker pull – Pulls an image or a repository from a registry
  • docker push – Pushes an image or a repository to a registry
  • docker export – Exports a container’s filesystem as a tar archive
  • docker exec – Runs a command in a run-time container
  • docker search – Searches the Docker Hub for images
  • docker attach – Attaches to a running container
  • docker commit – Creates a new image from a container’s changes

Check out the complete list of Docker commands in the Docker documentation

 

Examples of Using a Docker

  • You can run WordPress locally on your laptop by downloading Docker, without having to install Apache, PHP, MySQL etc. The Docker Toolbox creates a containerized version of Linux to run the Docker in a VM.
    • Download Docker Tool Box which will install the Oracle VirtualBox.
    • Install the Extension Pack in the VirtualBox.
    • Type $ docker run hello-world in the terminal to check if your installation has finished properly.
    • Search for a WordPress image on the Docker Hub to install WordPress locally.
  • Similarly, you can install DokuWiki using dockers.
  • Dockers can be used for testing SDN components

Here are a few samples to get your docker engine up and running.

*All the examples in this article are for installing Docker commands on Windows. You can always run it on a Linux VM.

45 Comments

  • Sreeja

    my containers are not listed…. i use linux…………..what should i do??

  • owenmorris

    Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

  • Pawan

    Very informational stuff on Docker. Thanks for sharing it.

  • Harley Demattia

    Greetings! Very helpful advice within this post! It’s the little changes that produce the greatest changes. Thanks for sharing!

  • Lily Buontempo

    I do enjoy the manner in which you have presented this problem and it does give me a lot of fodder for consideration. Nonetheless, from what I have witnessed, I only wish as the actual responses stack on that people continue to be on point and don’t start on a soap box of some other news du jour. Yet, thank you for this excellent point and while I do not agree with it in totality, I value your point of view.

  • Yolonda Mao

    some truly great blog posts on this site, thanks for contribution.

  • I have Joomla and a Joomla template(rt_refraction_j15) installed on my website. But i want the same template and css styling, as a basic HTML template, so i don’t have to use Joomla for editing. Is there an easy way to convert the template to basic HTML/CSS template?.

  • Shubham Kumar

    What command should you run to see all running container in docker?

  • Shiwanand

    NICE articulated in simple words
    Thanks!

  • Katy Meszaros

    Greetings! Very useful advice within this post! It is the little changes that will make the greatest changes. Thanks for sharing!

  • Preston Cienega

    I quite like reading an article that can make men and women think. Also, thank you for permitting me to comment!

  • Ezequiel Hemesath

    I AGREE

  • Zack Krick

    Does your website have a contact page? I’m having problems locating it but, I’d like to send you an e-mail. I’ve got some creative ideas for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it improve over time.

  • Eli Merna

    There is something in this. Thanks for the advice, how can I thank you?

  • Ruth Kaul

    Hello I am so delighted I found your blog page, I really found you by mistake, while I was browsing on Aol for something else, Regardless I am here now and would just like to say many thanks for a remarkable post and a all round exciting blog (I also love the theme/design), I don’t have time to browse it all at the minute but I have book-marked it and also added your RSS feeds, so when I have time I will be back to read a great deal more, Please do keep up the excellent work.

  • Bravo, I think this is a brilliant idea.

  • Sanjuana Detrick

    Hey! Do you use Twitter? I’d like to follow you if that would be okay. I’m absolutely enjoying your blog and look forward to new posts.

  • Jacqulyn Olberding

    Do you mind if I quote a few of your articles as long as I provide credit and sources back to your website? My blog is in the exact same area of interest as yours and my users would definitely benefit from some of the information you provide here. Please let me know if this okay with you. Cheers!

  • Giovanna Cartmell

    Bravo what a great message

  • January Kadner

    I really like your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz answer back as I’m looking to construct my own blog and would like to find out where u got this from. kudos

  • Marisela Mathies

    Greetings from California! I’m bored to tears at work so I decided to check out your site on my iphone during lunch break. I love the knowledge you provide here and can’t wait to take a look when I get home. I’m amazed at how quick your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, excellent blog!

  • Carol Suarez

    A person never realizes all his capabilities while he is chained to the ground. We must take off and conquer the skies.

  • Anas K

    What command should you run to see all running container in docker?

    Docker ps -here will list all running containers
    docker ps -a here will list all running and stoped containers

  • Marlin Leviner

    Your style is very unique compared to other folks I have read stuff from. Many thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark this blog.

  • Ludie Dubicki

    The next time I read a blog, Hopefully it doesn’t fail me as much as this particular one. I mean, I know it was my choice to read through, nonetheless I actually believed you would probably have something helpful to say. All I hear is a bunch of complaining about something you could fix if you weren’t too busy looking for attention.

  • May Bethurem

    Having read this I believed it was rather informative. I appreciate you spending some time and energy to put this article together. I once again find myself spending a significant amount of time both reading and posting comments. But so what, it was still worth it!

  • Amina Gomzales

    After checking out a few of the articles on your web site, I truly appreciate your technique of blogging. I book marked it to my bookmark site list and will be checking back soon. Please visit my web site too and tell me what you think.

  • Ammie Sloss

    Hey there! I just would like to offer you a big thumbs up for your great information you have got right here on this post. I am returning to your web site for more soon.

  • Shonda Organ

    This page certainly has all the info I wanted concerning this subject and didn’t know who to ask.

  • Buy Elite Proxies

    An impressive share, I just given this onto a colleague who was doing just a little evaluation on this. And he in actual fact purchased me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If attainable, as you develop into experience, would you mind updating your weblog with more details? It’s extremely useful for me. Massive thumb up for this blog put up!

  • Cyril Rodriuez

    You’ve made some decent points there. I checked on the net to find out more about the issue and found most people will go along with your views on this website.

  • docker ps -a

    it shows all the running dockers

  • Margarett Bindrup

    I agree with your points, superb post.

  • Hey there, You have done a fantastic job. I’ll definitely digg it
    and personally recommend to my friends. I’m confident
    they will be benefited from this website.

  • خدمات بیزون

    Hi, i think that i saw you visited my blog thus i came to “return the favor”.I am attempting to
    find things to enhance my website!I suppose its ok to
    use some of your ideas!!

Leave a Reply