Containerization using Dockerfile (contd..)
ADD and COPY: instructions to copy the contents into image
- For official docs of ADD Refer Here and COPY Refer Here
- Syntax
ADD <src> <dest>
COPY <src> <dest>
- ADD supports to copy from url’s whereas copy can copy from docker host into image
WORKDIR: working directory
- Refer Here for official docs
USER: sets the username
- Refer Here for the official docs
ARG: Parametrize while building image
- Refer Here for official docs
- ARG can provide a way to pass build time variables (they are available only during image building)
ENV: Environmental variables can be passed during container creation
- Refer Here for official docs
Building springpetclinic
- Refer Here for the changes to include add statement
- build the docker image with repo
petclinicand tagv1.0.0-slim

- Running application from root folder mightnot be a good idea, lets create a directory for petclinic and run our application from there.
- Running application with root previleges poses security risks, so lets run the spring petclinic with a new user called as
petclinic - Refer Here for the changes done to accomodate user and workdir
- build the docker image with repo
petclinicand tagv1.1.0-slim

- Now run the container in detached mode with name
pcnew

-
Build the image with username=qtdevops homedir=/lt
petclinicand tagqt-slim

-
Demonstrate usage of environmental variables, Refer Here for changes
- Now lets run the container and change the value of test while creation


Exercise
- Simple:
- Gameoflife application: Refer Here for war file
- requires:
- jdk8
- tomcat 8 or 9
- Copy the war file into webapps folder of tomcat 9
- Access the application by
<tomcat-url>/gameoflife
- requires:
- Gameoflife application: Refer Here for war file
- Tricky: Refer Here for nopCommerce on Linux
- Note: dont focus on database, configure the rest.
