Docker
Docker
-To avoid version Conflict and Environment unComfortability while modifying and
deploying (testing and running) Application in other platform we have docker
-Docker is an open platform
2)creat jar file: specify jar file name inide pom file
FROM openjdk:8 -) The from keyword is used to define the base image,on which we
building/working
5)create container:
*)Scrach:an explicitly empty image, especially for building images "FROM scratch"
-if the project in not depend on any dependent image we have to use from scratch
-This image is most useful in the context of building base images (such as debian
and busybox) or super minimal images (that contain only a single binary and
whatever it requires, such as hello-world).
-As of Docker 1.5.0 (specifically, docker/docker#8827), FROM scratch is a no-op in
the Dockerfile, and will not create an extra layer in your image (so a previously
2-layer image will be a 1-layer image instead).
-You can use Docker’s reserved, minimal image, scratch, as a starting point for
building containers. Using the scratch “image” signals to the build process that
you want the next command in the Dockerfile to be the first filesystem layer in
your image.
-While scratch appears in Docker’s repository on the hub, you can’t pull it, run
it, or tag any image with the name scratch. Instead, you can refer to it in your
Dockerfile. For example, to create a minimal container using scratch:
FROM scratch
COPY hello /
CMD ["/hello"]
*)Docker ps -a:to know which container are there and running
*) docker images
*)if remove the container we cannot strat the container bcz it not exist for once
use run command to create and run the container
*)To work on container through console log enter ctrl+c then container will stop /
we can work
*)docker system prune:it will remove all images and container not in use if put yes
= remove all (images dont attached to any container and container wchich are not
running containers deleted but its image will be present)
*) docker kill containername/Id : stop the running of container stop and kill are
similar but pause is different than both stop and kill
*)docker exec -it ContainerName bash/sh:to know the working directory created in
the container (it means interactive mode)
note: inside work directory jar file to be stored we can check...
to come out of it enter 'exit' command
*)docker pull mysql:to pull/docker the mysql from docker hub and to create the
mysql image
Docker-compose yml file(to create image and container when we have multiple docker
file)
version
services
-myappsevices
-build: . (. build the image using jar file which is present in current
folder)
-context: .
-dockerfile:
-image:
-container_name:
-port
-8080:8080
-9090:8080(WE CAN PROVIDE ANY NUMBER OF PORTS) LEFT:Docker
Container port, Right:tomcat server port
*)dockerFile:
*).yml file:
dockerFile
FROM Maven
WORKDIR /springboot-docker-app
COPY . .
RUN mvn clean install
CMD mvn spring-boot:run