Activity 2: Game of Life
- Install tomcat
- copy the war file into some directory (webapps)
- To remove container
docker container rm <container-id/name> docker rm <container-id/name>
- To remove all contianers
docker container rm -f $(docker container ls -a -q)
- To remove all images
docker image rm -f $(docker image ls -q) docker rmi <container-id/name>
# copy the gameoflife.war into webapps folder of tomcat
- Lets find a image with tomcat 8 or 9 with java 8
- Lets write a Dockerfile
FROM tomcat:8-jdk8 EXPOSE 8080 ADD https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/gameoflife.war /usr/local/tomcat/webapps/gameoflife.war CMD ["catalina.sh", "run"]
- Now build the image
docker image build -t gol:0.1 .
- Start the container
Lets start inspection
- Lets pull openjdk:8 image
- We are observing lot of things getting pulled as part of this image.
- Lets try one more image
- The stuff that is getting downloaded is called as image layer.
- Docker image is collection of image layers
- Lets inspect alpine:3
docker image inspect alpine:3with focus on layers
- Lets create a simple Dockerfile and create a image called as trail:1.0
FROM alpine:3 RUN touch 1.txt
* Now lets inspect trail:1.0
* Lets create one more version of trail:2.0
FROM alpine:3 RUN touch 1.txt RUN touch 2.txt
* In the above case two layers are reused and a new layer is created.
* Docker image layers are read-only.
* The container created from image gets an extra read/write layer.
* Any changes done will be present in the read/write layer of the container not image layer.
* Docker needs a special filesystem which can show the layers mounted on each other as normal file system. To make it possible docker has special file systems such as overlay and union file system.