Skip to content

Latest commit

 

History

History
55 lines (52 loc) · 3.61 KB

2. Docker Commands.md

File metadata and controls

55 lines (52 loc) · 3.61 KB
Commands Description
docker --version Shows the version of docker
docker version Show the Docker version information
docker version --format '{{.Server.Version}}'
docker version --format '{{.Client.Version}}'
docker info Display system-wide information
docker image pull alpine Pull an image or a repository from a registry
docker pull asadhussain1998/first-docker-app:latest
docker image push asadhussain1998/first-docker-app:latest Push an image to your Docker Hub account. In order to push an image you have to first login using " docker login " command
docker image ls List all the downloaded images
docker images
docker image ls -a List all the downloaded and hidden images
docker images -a
docker image rm alpine:latest Remove one or more images
docker image rm aamirpinger/helloworld
docker container run -it aamirpinger/helloworld sh Run a container in interactive mode
docker run -it aamirpinger/helloworld:latest sh
docker container run -d aamirpinger/flag:latest Run a container in detached mode
docker run -d aamirpinger/flag
docker container run -d -p 5010:80 aamirpinger/helloworld:latest Published the running container at 5010 port and 80 internal port
docker container run -d --name docker_app -p 5010:80 aamirpinger/helloworld:latest Customized container name
docker container run -d --name=flag_app -p 5020:80 aamirpinger/flag:latest
docker exec -it wizardly_nobel sh Go back to interactive mode
docker container ls List all the running containers
docker ps
docker container ls -a List all the running/stopped/puased containers
docker ps -a
docker container stop wizardly_nobel Stops a containers
docker stop wizardly_nobel
docker container start d43502edbc6c Starts a container
docker start d43502edbc6c
docker container rm wizardly_nobel Removes a container
docker rm wizardly_nobel
docker rm --force wizardly_nobel Removes the running container by force
docker rm $(docker ps -a -q) Removes all the stopped containers
docker build -t first-docker-app:latest . Build the image
docker history first-docker-app:latest Shows the history (short description) of an image
docker inspect first-docker-app:latest Shows inspect (descriptive) of an image
docker container run -it --name=test-app -v /home/asad/docker-save-file:/docker-container first-docker-application:latest sh Bind Mount an image. We bind mount the local directory with container
docker container run -d --name=test-app -p 5100:80 -v /home/asad/docker-save-file:/docker-container first-docker-application:latest
docker tag first-docker-app asadhussain1998/first-docker-app Gives new tag to an image
docker image tag first-docker-app asadhussain1998/first-docker-app
docker volume ls List all the created volumes
docker volume create my-volume Creates a volume
docker run -d -v my-volume:/usr/share/nginx/html -p 8000:80 nginx:latest We bind mount the volume with the container
docker run -d --name devtest --mount source=my-vol,target=/usr/share/nginx/html nginx:latest
docker run -d -it --name devtest --mount type=bind,source="$(pwd)"/myfolder,target=/app nginx:latest
docker run -d -it --name devtest -v "$(pwd)"/myfolder:/app nginx:latest
docker volume inspect my-volume Inspects a volume
docker container inspect wizardly_nobel Inspect a container

For more information visit the official website docker commands