Docker commands
Description of docker commands
docker pull
The command to pull the image from docker repository.
example:
foo@bar:$ docker pull python
docker images
List all the images in current docker daemon
example:
foo@bar:$ docker images
docker ps
List all the containers currently executing in the docker daemon
example:
foo@bar:$ docker ps
foo@bar:$ docker ps -a
docker rmi
Delete the selected images
example:
foo@bar:$ docker rmi <image id>
docker start
Start one or more stopped containers
example:
foo@bar:$ docker start <container ids>
docker stop
Stop one or more currently running containers
example:
foo@bar:$ docker stop <container ids>
docker inspect
Return low-level information on Docker objects
example:
foo@bar:$ docker inspect <container id>
docker stop
Stop one or more currently running containers
example:
foo@bar:$ docker stop <container ids>
docker prune
Remove all stopped containers
example:
foo@bar:$ docker docker container prune
Deploy the local docker registry
Run a local registry:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Copy an image from Docker Hub to your registry
Pull the ubuntu:16.04 image from Docker Hub.
docker pull ubuntu:16.04
Tag the image as
localhost:5000/my-ubuntu
This creates an additional tag for the existing image.
When the first part of the tag is a hostname and port, Docker interprets this as the location of a registry, when pushing.
docker tag ubuntu:16.04 localhost:5000/my-ubuntu
Push the image to the local registry running at localhost:5000:
docker push localhost:5000/my-ubuntu
Remove the locally-cached ubuntu:16.04 and localhost:5000/my-ubuntu images
docker image remove ubuntu:16.04
docker image remove localhost:5000/my-ubuntu
Stop a local registry
docker container stop registry
To remove the container, use docker container rm.
docker container stop registry && docker container rm -v registry