Building game of life container
Building game of life container
-----------------------------------------
Manual Steps:
install java8 (openjdk8)
install tomcat 7
tomcat directory/webapps/
(re)start tocmat
works on port 8080
Game-of-life war file has been uploaded into S3 bucket:
========================================
Game-of-life
How to pull tomcat from git:(Now here we r downloading tomcat8)
--------------------------------------
ubuntu@ip-172-31-2-125:~$ docker image pull tomcat:8
8: Pulling from library/tomcat
ab1fc7e4bf91: Pull complete
35fba333ff52: Pull complete
f0cb1fa13079: Pull complete
3d79c18d1bc0: Pull complete
ff1d0ae4641b: Pull complete
8883e662573f: Pull complete
adab760d76bd: Pull complete
86323b680e93: Pull complete
14a2c1cdce1c: Pull complete
ee59bf8c5470: Pull complete
067f988306af: Pull complete
Digest: sha256:296b26baeee450a9814b2733e9d085f3d26af1c48e5fdc2000496ff7e12bc897
Status: Downloaded newer image for tomcat:8
To cretae container:
===============
i => interactive mode
t => terminal
ubuntu@ip-172-31-2-125:~$ docker container run -ti tomcat:8 /bin/bash
root@aa326d9f8eb0:/usr/local/tomcat#
=> Then goto "webapps" folder and copy .war file:
root@aa326d9f8eb0:/usr/local/tomcat# ls
BUILDING.txt LICENSE README.md RUNNING.txt conf lib native-jni-lib webapps
CONTRIBUTING.md NOTICE RELEASE-NOTES bin include logs temp work
root@aa326d9f8eb0:/usr/local/tomcat# cd webapps/
root@aa326d9f8eb0:/usr/local/tomcat/webapps# ls -ltr
total 20
drwxr-xr-x 5 root root 4096 Jan 23 07:56 manager
drwxr-xr-x 5 root root 4096 Jan 23 07:56 host-manager
drwxr-xr-x 6 root root 4096 Jan 23 07:56 examples
drwxr-xr-x 14 root root 4096 Jan 23 07:56 docs
drwxr-xr-x 3 root root 4096 Jan 23 07:56 ROOT
root@aa326d9f8eb0:/usr/local/tomcat/webapps# wget https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war
--2019-02-06 15:55:50-- https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war
Resolving s3.us-east-2.amazonaws.com (s3.us-east-2.amazonaws.com)... 52.219.88.51
Connecting to s3.us-east-2.amazonaws.com (s3.us-east-2.amazonaws.com)|52.219.88.51|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3192502 (3.0M) [binary/octet-stream]
Saving to: ‘gameoflife.war’
gameoflife.war 100%[===================================>] 3.04M --.-KB/s in 0.06s
2019-02-06 15:55:50 (47.8 MB/s) - ‘gameoflife.war’ saved [3192502/3192502]
Dockerfile:(to build docker image)
===============
ADD : add support from URL
add <source> <destination>
=> source can be anything local or URL(HTTP)
COPY:
copy <source> <destination>
=> source is local
OR
ubuntu@ip-172-31-2-125:~/images/gol$ docker image build -t gol:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM tomcat:8
---> 7ee26c09afb3
Step 2/5 : LABEL "AUTHOR"="ganesh"
---> Running in 1f0998c3fea5
Removing intermediate container 1f0998c3fea5
---> 3e56156bde58
Step 3/5 : ADD https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war /usr/local/tomcat/webapps/gameoflife.war
Downloading 3.193MB/3.193MB
---> ea17d0a299eb
Step 4/5 : EXPOSE 8080
---> Running in 14b137b9e0a5
Removing intermediate container 14b137b9e0a5
---> b3f3f9a9c80f
Step 5/5 : CMD ["catalina.sh", "run"]
---> Running in 83d5cf7bde8a
Removing intermediate container 83d5cf7bde8a
---> c839cefc1903
Successfully built c839cefc1903
Successfully tagged gol:1.0
ubuntu@ip-172-31-2-125:~/images/gol$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gol 1.0 c839cefc1903 4 seconds ago 466MB
To run docker in background mode:
=========================
Note: Here your EC2 machine 80 port is linked with 8080 port of docker container.
ubuntu@ip-172-31-2-125:~/images/gol$ docker container run -d -p 80:8080 gol:1.0
9379c92561bc8a3629742f329e5d5cbd0c133ed46ad99f2fc0cb256cd2ba15fa
ubuntu@ip-172-31-2-125:~/images/gol$
To check container status:
===================
ubuntu@ip-172-31-2-125:~/images/gol$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9379c92561bc gol:1.0 "catalina.sh run" About a minute ago Up About a minute 0.0.0.0:80->8080/tcp hardcore_mccarthy
ubuntu@ip-172-31-2-125:~/images/gol$
-----------------------------------------
Manual Steps:
install java8 (openjdk8)
install tomcat 7
tomcat directory/webapps/
(re)start tocmat
works on port 8080
Game-of-life war file has been uploaded into S3 bucket:
========================================
Game-of-life
How to pull tomcat from git:(Now here we r downloading tomcat8)
--------------------------------------
ubuntu@ip-172-31-2-125:~$ docker image pull tomcat:8
8: Pulling from library/tomcat
ab1fc7e4bf91: Pull complete
35fba333ff52: Pull complete
f0cb1fa13079: Pull complete
3d79c18d1bc0: Pull complete
ff1d0ae4641b: Pull complete
8883e662573f: Pull complete
adab760d76bd: Pull complete
86323b680e93: Pull complete
14a2c1cdce1c: Pull complete
ee59bf8c5470: Pull complete
067f988306af: Pull complete
Digest: sha256:296b26baeee450a9814b2733e9d085f3d26af1c48e5fdc2000496ff7e12bc897
Status: Downloaded newer image for tomcat:8
To cretae container:
===============
i => interactive mode
t => terminal
ubuntu@ip-172-31-2-125:~$ docker container run -ti tomcat:8 /bin/bash
root@aa326d9f8eb0:/usr/local/tomcat#
=> Then goto "webapps" folder and copy .war file:
root@aa326d9f8eb0:/usr/local/tomcat# ls
BUILDING.txt LICENSE README.md RUNNING.txt conf lib native-jni-lib webapps
CONTRIBUTING.md NOTICE RELEASE-NOTES bin include logs temp work
root@aa326d9f8eb0:/usr/local/tomcat# cd webapps/
root@aa326d9f8eb0:/usr/local/tomcat/webapps# ls -ltr
total 20
drwxr-xr-x 5 root root 4096 Jan 23 07:56 manager
drwxr-xr-x 5 root root 4096 Jan 23 07:56 host-manager
drwxr-xr-x 6 root root 4096 Jan 23 07:56 examples
drwxr-xr-x 14 root root 4096 Jan 23 07:56 docs
drwxr-xr-x 3 root root 4096 Jan 23 07:56 ROOT
root@aa326d9f8eb0:/usr/local/tomcat/webapps# wget https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war
--2019-02-06 15:55:50-- https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war
Resolving s3.us-east-2.amazonaws.com (s3.us-east-2.amazonaws.com)... 52.219.88.51
Connecting to s3.us-east-2.amazonaws.com (s3.us-east-2.amazonaws.com)|52.219.88.51|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3192502 (3.0M) [binary/octet-stream]
Saving to: ‘gameoflife.war’
gameoflife.war 100%[===================================>] 3.04M --.-KB/s in 0.06s
2019-02-06 15:55:50 (47.8 MB/s) - ‘gameoflife.war’ saved [3192502/3192502]
Dockerfile:(to build docker image)
===============
ADD : add support from URL
add <source> <destination>
=> source can be anything local or URL(HTTP)
COPY:
copy <source> <destination>
=> source is local
FROM tomcat:8
LABEL "AUTHOR"="ganesh"
ADD https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war /usr/local/tomcat/webapps/gameoflife.war
EXPOSE 8080
CMD ["catalina.sh", "run"]
OR
FROM tomcat:8
LABEL "AUTHOR"="ganesh"
RUN cd webapss && wget https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war
EXPOSE 8080
CMD ["catalina.sh", "run"]
ubuntu@ip-172-31-2-125:~/images/gol$ docker image build -t gol:1.0 .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM tomcat:8
---> 7ee26c09afb3
Step 2/5 : LABEL "AUTHOR"="ganesh"
---> Running in 1f0998c3fea5
Removing intermediate container 1f0998c3fea5
---> 3e56156bde58
Step 3/5 : ADD https://s3.us-east-2.amazonaws.com/ganesh39/gameoflife.war /usr/local/tomcat/webapps/gameoflife.war
Downloading 3.193MB/3.193MB
---> ea17d0a299eb
Step 4/5 : EXPOSE 8080
---> Running in 14b137b9e0a5
Removing intermediate container 14b137b9e0a5
---> b3f3f9a9c80f
Step 5/5 : CMD ["catalina.sh", "run"]
---> Running in 83d5cf7bde8a
Removing intermediate container 83d5cf7bde8a
---> c839cefc1903
Successfully built c839cefc1903
Successfully tagged gol:1.0
ubuntu@ip-172-31-2-125:~/images/gol$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
gol 1.0 c839cefc1903 4 seconds ago 466MB
To run docker in background mode:
=========================
Note: Here your EC2 machine 80 port is linked with 8080 port of docker container.
ubuntu@ip-172-31-2-125:~/images/gol$ docker container run -d -p 80:8080 gol:1.0
9379c92561bc8a3629742f329e5d5cbd0c133ed46ad99f2fc0cb256cd2ba15fa
ubuntu@ip-172-31-2-125:~/images/gol$
To check container status:
===================
ubuntu@ip-172-31-2-125:~/images/gol$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9379c92561bc gol:1.0 "catalina.sh run" About a minute ago Up About a minute 0.0.0.0:80->8080/tcp hardcore_mccarthy
ubuntu@ip-172-31-2-125:~/images/gol$
Comments
Post a Comment