Docker images
- Consider this dockerfile
FROM openjdk:8
LABEL author="shaik khaja ibrahim"
LABEL org="Learning Thoughts"
ADD https://referenceappkhaja.s3-us-west-2.amazonaws.com/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar spring-petclinic.jar
EXPOSE 8080
CMD [ "java", "-jar", "spring-petclinic.jar" ]
- while building this image we might have a new URL where the image is to be downloaded and file might have a new name
- Lets start with parametrizing the url to download the image
- Lets use ARG instruction which allows values to be changed while building the image Refer Here

- Lets create one container from the image built. Login into the container & verify the environmental variables

- Refer Here for the changes done so far
- ENV variables are available while builidng the image and also while the container is running as environmental variables
- Refer Here for the changes done to docker file
We can use docker to build applications and package them as containers
- Lets manually build game of life using docker
- For game of life code Refer Here
- Commands to build
- Ensure maven is installed
mvn packageis the command
- Now lets try to create a container with image where maven is installed.
docker container run -it maven:3-openjdk-8 /bin/bash
git clone https://github.com/wakaleo/game-of-life.git
cd game-of-life
mvn package
- Once we execute these commands we can build the application inside the container.
- So, can we container building technique as discussed above completely to build a docker image?
- While i run my application i might not build the build system capabilities
- Docker Image should be slim, so we need a approach where we build packages (application binaries) in one container copy them into lightweight image to create docker application image.
- This can be achieved by Docker Multi Staged Builds.
