Docker

|
Divnesh BLOG

If 192.168.99.100 does not work, you can find the IP by using the command docker-machine ip


docker --version    to check version

docker run <image> run in docker terminal

docker run -p <hostport>:<container port> <> run image with port details

docker run -p <hostport>:<container port> - d <> run image in detached mode will generate a <id>

Or

docker container run -p <hostport>:<container port> - d <>  

docker logs <id> just run and give port details in detached mode

docker logs -f <id> tailing the logs

docker container ls to see all containers running in this machine currently

docker images

docker container ls -a to see all containers in this machine both stopped/running

docker container stop <id>  to stop the running containers (Gracefull stop) -  signal SIGTERM

docker container kill <id>  to stop the running containers (immediate stop) -  signal SIGKILL

docker tag <artifactid>:<version> <artifactid>:<version> to copy the atrifact to new one

docker pull <image>

docker search <image> search the image which has ref in dockerhub

docker image history <id> view the history of image

docker image inspect <id> inspect the image

docker image remove <id> remove from local

docker  pause <id> or docker container pause pause the container

docker container unpause <id>  resume the container

docker container prune remove all the stopped containers

docker container run -p <hostport>:<container port> -m 512m --cpu-quota 5000 - d <> 100000 - 100%,5000-5%

docker container run -p <hostport>:<container port> - d --restart:always <> Default value of restart is No.

docker events - view all process in docker

docker stats

docker top <id>

docker system df show system different docker property


Docker hub - registry - contains number repository --  

Image is a static version and container running version


Create a image using openjdk manually

docker run -dit openjdk:8-jdk-alpine D - detached

I - interactive

T -- tty

It - allows to run command in running container

Will create a <containerNOpenJdk8>

docker container exec <containerNOpenJdk8> ls /tmp to check what is inside the openjdk:8-jdk-alpine containers tmp folder

docker container cp target/<api>.jar <containerNOpenJdk8>:/tmp  copy to tmp folder inside openjdk:8-jdk-alpine

docker container commit <containerNOpenJdk8> <folder>/<api>:<version> Create a image but it will not run the image

docker container commit --change='CMD ["java","-jar","/tmp/<api>.jar"]' <containerNOpenJdk8> <folder>/<api>:<version>


Create a image using Dockerfile


FROM openjdk:8-jdk-alpine Dockerfile

EXPOSE 8080

ADD target/hello-world-rest-api.jar hello-world-rest-api.jar

ENTRYPOINT ["sh", "-c", "java -jar /hello-world-rest-api.jar"]

Docker build -t <folder>/<api>:version .    to run the api with docker file

https://github.com/in28minutes/docker-crash-course/






Featured Post

HTML cheetsheet

List: Link tgs Dropdown

Popular Post

(C) Copyright 2018, All rights resrved InShortView. Template by colorlib