Building Docker Images
app
image
containers
registry
Imperative
Declarative
VM Like
Dockerfile
(manual)
(automated)
registry
image
image
intermediate container
code
cp
build
commit
pull
run
push
pull image
run container
copy source code
build/compile
commit
push
dockerfile
FROM
RUN
COPY
EXPOSE
CMD
dockerfile
FROM
RUN
COPY
EXPOSE
CMD
docker build
image
http://hub.docker.com
sign up
Spring boot application
Uses HSQLDB / MySQL as DB backend
https://github.com/devopsdemoapps/spring-petclinic
Build step
Package Step
registry
maven
maven
build container
code
mount
build
artifact
pull
run
host
registry
java
java
package container
artifact
cp
commit
pull
run
push
host
image
image
registry
centos
install jdk
install mvn
mvn compile
mvn
mvn compile
https://gist.github.com/initcron/61046646e5afcd1f0cb7fef9eebe2b75
FROM java:8-jre-alpine
WORKDIR /
COPY target/spring-petclinic-*.jar app
EXPOSE 8080
CMD java -jar app
docker image build -t <dockrhub user id>/petclinic:v2 .
docker image ls
dot (current directory)
docker container run -idt --name pc <dockrhub user id>/petclinic:v2
docker container ls
docker logs pc
docker image tag <dockrhub user id>/petclinic:v2 <dockrhub user id>/petclinic:latest
docker image ls
docker image push <dockrhub user id>/petclinic:latest
docker image push <dockrhub user id>/petclinic