0% found this document useful (0 votes)
77 views

Command Description Docker Pull

This document provides descriptions for various Docker commands. It describes commands for pulling images, building images, listing images and containers, inspecting images, tagging images, pushing images to a registry, running containers, managing containers, creating and mounting volumes, and pushing custom images to Docker Hub. The commands cover the essential tasks for working with Docker images and containers like building, running, managing, and distributing custom applications as container images.

Uploaded by

Waleed Afr
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

Command Description Docker Pull

This document provides descriptions for various Docker commands. It describes commands for pulling images, building images, listing images and containers, inspecting images, tagging images, pushing images to a registry, running containers, managing containers, creating and mounting volumes, and pushing custom images to Docker Hub. The commands cover the essential tasks for working with Docker images and containers like building, running, managing, and distributing custom applications as container images.

Uploaded by

Waleed Afr
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Command Description

docker pull <image-name>:<tag> Pulls the image from the docker hub

Builds the image from the Dockerfile with the


docker build -t <image-name>:<tag> .
mentioned name and tag

Shows the list of the images present on your system.


docker image ls
short-hand 'docker images'

Displays the only running containers. short-hand


docker container ls
'docker ps'

Displays all the containers present on your system.


docker container ls –a
short-hand 'docker ps -a'

Shows the detailed information about the image in


docker inspect <image name>:<tag>
JSON format.

docker history <image name>:<tag> Used to inspect the layers of the image.

docker tag <source-image>:<tag> <username/new-image-


Create a tag of the new image that refers to source
name>:<tag>
image.

docker push user/<image-name>:<tag> Push an image to a registry

Remove the image. short-hand 'docker rmi <image


docker image rm <image name>:<tag>
name>:<tag>'

docker run --name <container_name> -p <host_port : Create the container with the specified name and
container_port> -d <image_name> assign the specified port from the image.
Command Description

To run a container from an image in an interactive


docker run --name <container-name> -it -p <host_port :
mode. Press Ctrl + pq it will detach terminal and
container_port> <image-name>:<tag> sh
leave container running in background.

To go in the running container shell. Write exit to


docker exec -it <container_name> sh
detach the terminal

docker stop container_name It will stop the running container.

docker start container_name Start the stopped container

docker rm container_name Remove the container.

docker logs container_name fetch the logs of the container

docker volume create my-vol Create your Volume for Persistent Data

docker volumes ls List down the volumes

docker volume inspect my-vol inspect the volumes

docker volumes rm my-vol remove volume

docker run -d --name mycont -v my-vol:/usr/share/nginx/html


start container with -v flag (volume mount)
nginx:latest

docker run -d --name devtest --mount source=my-


start container with --mount flag
vol,target=/usr/share/nginx/html nginx:latest

docker run -d -it --name devtest -v "$(pwd)"/myfolder:/app


start container with bind mounts and -v flag
nginx:latest
Command Description

docker run -d -it --name devtest --mount type=bind,source="$


start container with bind mounts and -mount flag
(pwd)"/myfolder,target=/app nginx:latest

Docker container run –d aamirpinger/flag

Docker conatainer run –d –p 5010:80 aamirpinger/helloworld (to check on browser type


localhost:5010 and then enter it will shows your work that u have done it)

CUSTOM CONTAINER NAME.

Docker container run -d --name afridi_app –p 5020:80 aamirpinger/flag (to check on browser type
localhost:5010 and then enter it will shows your work that u have done it)

PUSHING IMAGE AND TAGGING


If image saved with the name of like node-app-image( it will be not pushing on docker hub bcz there is no
repository name. there are two method to push or upload image.
1. TAG NAMING
Docker tag node-app-image aamirpiner/node-app-image or (node-app)
To verify it docker images enter
NOW TO PUSH IMAGE
docker image push aamirpinger/node-app-image enter
TO RUN THIS IMAGE
docker run –d –name node-app –p 8700:8080 aamirpinger/node-app-image (now check it on browser type:
localhost:8700 enter)

2. Build image
Docker build –t aamirpinger/node-app-image . ( it will create new image

docker inspect node-app-image


docker history node-app-image

You might also like