Basic Docker Commands With Examples – Docker

Basic Docker Commands

$ docker --version

This command returns the version of Docker which is installed

docker pull

$ docker pull ubuntu

This command pulls a new Docker image from the Docker Hub

docker images

$ docker images

This command lists down all the images in your local repo

docker container

$ docker container logs

This command is used to perform various operations on the
container. Refer to www.docs.docker.com for more info.

$ docker container kill
$ docker container rm
$ docker container run
$ docker container start

docker login

$ docker login

This command is used to Login to Docker Hub repo from the CLI

docker push

$ docker push vardhanns/MyUbuntuImage

This command pushes a Docker image on your local repo to the Docker Hub

docker ps

$ docker ps

This command lists all the running containers in the host

If -a flag is specified, shutdown containers are also displayed

$ docker ps -a

docker rm

$ docker rm fe6e370a1c9c

This command removes the container whose Container ID is specified in arguments.

docker rmi

$ docker rmi MyUbuntuImage

This command removes the image whose name has been specified in arguments

docker exec

$ docker exec -it fe6e37ea1c9c bash

This command is used to access an already running container and perform operations inside the container

docker export

$ docker export -- output-"latest.tar" mycontainer

This command is used to export a Docker image into a tar file in your local system

docker import

$ docker import /home/edureka/Downloads/demo.tgz

This command is used to import the contents of a tar file(usually a Docker image) into your local repo

Leave a Reply

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