Few Useful Docker Commands
- If dockerfile is present in the same directory:
docker build -t <name-of-docker-image> .
[NOTE] Don't forget to put dot at the end.
[NOTE] Docker enforce image name to be in lowercase.
- If dockerfile is present some other directory:
docker build -t <name-of-docker-image> <path or url>
Syntax: docker pull
docker pull centos
Syntax: docker run
docker run centos
Syntax: docker run -p : -e ref-data-app
docker run -p 9080:9080 -e JAVA_OPTS="-Dserver.port=9080" my-docker-image
-
all stopped containers
-
all networks not used by at least one container
-
all dangling images
-
all build cache
docker system prune
docker rmi <image-name>
docker rm <container-name>
docker rmi $(docker images -q)
docker container prune
docker stop <container-id>
docker save -o <save image to path> <image name>
docker load -i <path to image tar file