April 28, 2022

Docker

docker –version

docker pull <image name> # This command is used to pull images from the docker

docker run -it -d <image name> </br> # This command is used to create a container from an image

docker ps # This command is used to list the running containers

docker ps -a # This command is used to show all the running and exited containers

docker exec -it <container id> bash # This command is used to access the running container

docker stop

docker kill

docker commit

docker login

docker push

docker images

docker rm

docker rmi

docker build

List of the images

docker image

List of the started containers

docker ps

List of all containers (include stoped)

docker ps

Sample Dockerfile for Java

FROM openjdk:8-jdk-alpine

JAR_FILE=target/*.jar

COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java","-jar","/app.jar"]