🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
All the important and commonly used docker commands for your quick reference. This is a cheat sheet for docker commands for managing images and containers.
Build an image from a Dockerfile:
docker build -t <image-name> <path to docker file>For example:
docker build -t springboot-docker-image .List docker images:
docker imagesDisplay detailed information on one or more images:
docker inspect <docker-image>docker inspect springboot-docker-imageShow the history of an image:
docker image histroy <docker-image>docker image history springboot-docker-imageCreate a tag TARGET_IMAGE that refers to SOURCE_IMAGE:
docker image tag <docker-image> <docker-image:tag>docker image tag springboot-docker-image springboot-docker-image:0.1Remove or Delete a Docker Image
This command is used to delete an image from local storagedocker rmi <image-id>/<image-name>docker rmi springboot-docker-imageRemove or Delete a Docker Image Forcefully:
This command is used to delete an image from local storagedocker rmi -f <image-id>/<image-name>docker rmi -f springboot-docker-imagePull an image or a repository from a registry:
docker image pull <docker-image>/<repository-name>docker image pull rabbitmqRemove unused images:
docker image prunePush an image or a repository to a registry:
To push a local image to the docker registry, you need to associate the local image with a repository on the docker registry.To tag an image, we use the docker tag command:
docker tag image username/repository:tag
Finally, use the docker push command to push the tagged image to the docker hub like so -
docker push username/repository:tagCommand to tag the image:
docker tag springboot-docker-image javaguides/springboot-docker-image:1.0.RELEASEdocker push javaguides/springboot-docker-image:1.0.RELEASERun the docker image in a new container:
docker run [docker_image]
For example:docker run -p 8080:8080 springboot-docker-image
-p option to map host port with container port.
docker run [docker_image]docker run -p 8080:8080 springboot-docker-imageGive a name to the container:
docker run --name <container-name> <image-name>
For example:docker run --name springboot-docker-container -p 8080:8080 springboot-docker-image
docker run --name <container-name> <image-name>docker run --name springboot-docker-container -p 8080:8080 springboot-docker-imageRun container in background and print container ID:
docker run -d <docker-image>
-d option to run the container in detached mode (background).For example:docker run -d -p 8080:8080 springboot-docker-image
docker run -d <docker-image>docker run -d -p 8080:8080 springboot-docker-imageFetch the logs of a container
docker logs -f <container-id>/<container-name>
For example:docker logs -f springboot-docker-container
docker logs -f <container-id>/<container-name>docker logs -f springboot-docker-containerList all the docker running containers:
docker ps
docker psDocker container pause:
docker container pause <container-id>/<container-name>
For example:docker container pause springboot-docker-container
docker container pause <container-id>/<container-name>docker container pause springboot-docker-containerDocker container unpause:
docker container unpause <container-id>/<container-name>
For example:docker container unpause springboot-docker-container
docker container unpause <container-id>/<container-name>docker container unpause springboot-docker-containerKill docker container:
docker kill <container-id>/<container-name>
For example:
docker kill springboot-docker-container
This command kills the container by stopping its execution immediately. The difference between ‘docker kill’ and ‘docker stop’ is that ‘docker stop’ gives the container time to shutdown gracefully, in situations when it is taking too much time for getting the container to stop, one can opt to kill it.
docker kill <container-id>/<container-name>docker kill springboot-docker-containerStop running container:
docker stop <container-id>/<container-name>
For example:
docker stop springboot-docker-container
docker stop <container-id>/<container-name>docker stop springboot-docker-containerList all running and exited containers:
docker container ls -a
docker container ls -aRemove all stopped containers:
docker container prune
docker container pruneRelated Tutorials
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment