Skip to main content

Command Palette

Search for a command to run...

Docker Commands For Beginner

Published
โ€ข3 min read
Docker Commands For Beginner
S

I am a DevOps learner.

Introduction to docker

Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers. These containers are isolated from one another and use a single operating system kernel. The Best thing about these containers is they use fewer resources than a virtual machine. The Docker tool is useful in deploying, shipping and testing your applications. The Docker daemon is responsible for managing these containers. And Docker CLI (command line) helps us to communicate with the docker daemon. You can read the docker's official documentation page to learn more about docker. Here is the link to the page

๐Ÿ”— "https://docs.docker.com/get-started/overview/".

Docker Commands

Below is the list of docker commands that are useful for beginners. I have given a short description of each command.

  1. docker version

    This command will let you know the docker version installed on your Operating system.

  2. docker pull

     docker pull [image name][:tag name]
    

    This command is used to pull the image from the docker hub repository. Type the docker pull command followed by the image name. Then followed by the tag name to mention the version of the image. By default, the latest tag is used in case you don't mention the tag name.

  3. docker run

     docker run [options] image [command] [argument]
    

    This command is used to run the container using the image provided. followed by the container name and some of the arguments to pass after the container starts. for example:

    docker run --name myubuntu -it ubuntu

    This will create an ubuntu container named myubuntu using the provided image name. Here the -it is used to open the terminal of the container after it starts.

  4. docker ps

     docker ps [options]
    

    This command is used to list all the running containers in the background. You can use -a option to get the list of all the containers running, stopped or exited.

  5. docker images

    This command is used to list all the images downloaded on the system.

  6. docker stop

     docker stop [container name or ID]
    

    This command is used to stop the running container. Type the docker stop command followed by the container name or container ID.

    Note: Every container gets a unique Id number after we create it.

  7. docker rm

     docker rm [container name or ID]
    

    This command is used to remove the container. Type the docker rm command followed by container name or Id.

    Note: You should stop the container before you remove it or use --force option along with the rm command to remove it.

    docker rm --force myubuntu

  8. docker logs

     docker logs [container name or Id]
    

    This command is used to check the logs of all the docker containers with the corresponding contained id mentioned in the command.

  9. docker rmi

     docker rmi [Image name or Id]
    

    This command is used to remove the image. Type the docker rmi command followed by the image name or Id.

  10. docker create

    docker create [container name] image name
    

    This command is a combination of pull and run commands. Type docker create command followed by --name command to provide a container name and then followed by the image name you want to use. for example:

    docker create --name myubuntu ubuntu .

I hope these commands may help you to begin with docker. Thank you