docker

Intro

A container is a standard unit of software that packages up code and all its dependencies.

A Docker container image is a lightweight, standalone, executable package unit of software that includes everything needed to run an application:

  • code,

  • runtime,

  • system tools,

  • system libraries

  • debuggin

  • and settings.

Containers isolate software from its environment and ensure that it works uniformly despite differences for instance between development and staging.

Example

Spring Boot is great for running inside a Docker container. Spring Boot applications ‘just run’. For running it in a Docker container, you only require a base OS and a JDK and then build into a Docker container.

Images (like Docker images) are read-only templates containing instructions for creating a container. A Docker image creates containers to run on the Docker platform.

Dockerfile (edit with sublime without extension and named Dockerfile) to define all operations

FROM adoptopenjdk/openjdk11:alpine-jre

MAINTAINER albertprofe

COPY springbootClient-0.0.1-SNAPSHOT.jar example1.jar

ENTRYPOINT ["java","-jar","example1.jar"]

From docker hub choose (and dockerfile will fetch) OS and JDK image

You need to have a ready to run jar spring boot package

springbootClient-0.0.1-SNAPSHOT.jar

build the image:

>docker build

run the docker:

> docker run