How do SSH into a running container?

by XDK 25. August 2019 17:37

Explanation:

Command to get the name of the existing container

ubuntu@ip-172-31-57-91:/opt/HelloWorld$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2a41bd524e93 xdkdockerhub/xdkdockerrepo:xdk_helloworld_V1 "catalina.sh run" 5 minutes ago Up 5 minutes 0.0.0.0:80->8080/tcp sweet_hypatia

Command to get a bash shell in the container.
ubuntu@ip-172-31-57-91:/opt/HelloWorld$ docker exec -it sweet_hypatia bash

Verify with basic commands

root@2a41bd524e93:/usr/local/tomcat# ls -a

. BUILDING.txt LICENSE README.md RUNNING.txt conf lib native-jni-lib webapps
.. CONTRIBUTING.md NOTICE RELEASE-NOTES bin include logs temp work

root@2a41bd524e93:/usr/local/tomcat# ls -al
total 168
drwxr-sr-x 1 root staff 4096 May 16 00:50 .
drwxrwsr-x 1 root staff 4096 May 8 13:20 ..
-rw-r--r-- 1 root root 19539 May 4 09:22 BUILDING.txt
-rw-r--r-- 1 root root 5407 May 4 09:22 CONTRIBUTING.md
-rw-r--r-- 1 root root 57092 May 4 09:22 LICENSE
-rw-r--r-- 1 root root 1726 May 4 09:22 NOTICE
-rw-r--r-- 1 root root 3255 May 4 09:22 README.md
-rw-r--r-- 1 root root 7139 May 4 09:22 RELEASE-NOTES
-rw-r--r-- 1 root root 16262 May 4 09:22 RUNNING.txt
drwxr-xr-x 2 root root 4096 May 16 00:50 bin
drwxr-sr-x 1 root root 4096 Aug 25 11:56 conf
drwxr-sr-x 2 root staff 4096 May 16 00:50 include
drwxr-xr-x 2 root root 4096 May 16 00:49 lib
drwxrwxrwx 1 root root 4096 Aug 25 11:56 logs
drwxr-sr-x 3 root staff 4096 May 16 00:50 native-jni-lib
drwxr-xr-x 2 root root 4096 May 16 00:49 temp
drwxr-xr-x 1 root root 4096 Aug 25 11:56 webapps
drwxrwxrwx 1 root root 4096 Aug 25 11:56 work
root@2a41bd524e93:/usr/local/tomcat# exit
exit
ubuntu@ip-172-31-57-91:/opt/HelloWorld$

Tags:

Amazon Web Service | Azure Native DevOps | Docker | Microsoft Azure Services

How to pull an image from Docker Hub?

by XDK 25. August 2019 17:17

Explanation:

Login to the Docker Hub from the command line

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker login --username=xdkdockerhub
Password:
WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

Command to pull the image from the docker hub repository.

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker pull xdkdockerhub/xdkdockerrepo:xdk_helloworld_V1
xdk_helloworld_V1: Pulling from xdkdockerhub/xdkdockerrepo
c5e155d5a1d1: Already exists
221d80d00ae9: Already exists
4250b3117dca: Already exists
d1370422ab93: Already exists
deb6b03222ca: Already exists
9cdea8d70cc3: Already exists
968505be14db: Already exists
04b5c270ac81: Already exists
301d76fcab1f: Already exists
57ca7a0b9e79: Already exists
3c1d6826d7a3: Already exists
24ab01b57aed: Pull complete
Digest: sha256:47252a9c0bf7f4fe9a024ab69a7d709db3d27d409cbc66dfcddcfc1a20a04cda
Status: Downloaded newer image for xdkdockerhub/xdkdockerrepo:xdk_helloworld_V1

Verify the image.

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xdkdockerhub/xdkdockerrepo xdk_helloworld_V1 a801afaa1782 39 minutes ago 473MB
tomcat jre8 3639174793ba 3 months ago 463MB

Command to run the xdk_helloworld docker image and change the container to listen to port 80 instead of tomcat's default port 8080 at runtime.

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker run -p 80:8080 xdkdockerhub/xdkdockerrepo:xdk_helloworld_V1

Open http://34.204.171.134/HelloWorld/ in a browser to see the HelloWorld web is application running.

Tags:

Amazon Web Service | Azure Native DevOps | Docker | Microsoft Azure Services

How to push an image to Docker Hub?

by XDK 25. August 2019 17:02

Explanation:

Sign up for an account on https://hub.docker.com/ to push and share the custom image in docker hub.

Login to the Docker Hub from the command line

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker login --username=xdkdockerhub
Password:
WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xdk_helloworld latest a801afaa1782 20 seconds ago 473MB
tomcat jre8 3639174793ba 3 months ago 463MB

Command to tag the image

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker tag xdk_helloworld xdkdockerhub/xdkdockerrepo:xdk_helloworld_V1

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xdk_helloworld latest a801afaa1782 18 minutes ago 473MB
xdkdockerhub/xdkdockerrepo xdk_helloworld_V1 a801afaa1782 18 minutes ago 473MB
tomcat jre8 3639174793ba 3 months ago 463MB

Command to push the image to the docker hub repository

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker push xdkdockerhub/xdkdockerrepo
The push refers to repository [docker.io/xdkdockerhub/xdkdockerrepo]
dee4d54a7f75: Pushed
f24d8b358bb1: Mounted from library/tomcat
c8bcc49b9925: Mounted from library/tomcat
f0e1731fd286: Mounted from library/tomcat
2b6c38ff3137: Mounted from library/tomcat
d38f3d5a39fb: Mounted from library/tomcat
fe60061c6c4e: Mounted from library/tomcat
7d63f8777ebf: Mounted from library/tomcat
1b958b53b256: Mounted from library/tomcat
2c719774c1e1: Mounted from library/tomcat
ec62f19bb3aa: Mounted from library/tomcat
f94641f1fe1f: Mounted from library/tomcat
xdk_helloworld_V1: digest: sha256:47252a9c0bf7f4fe9a024ab69a7d709db3d27d409cbc66dfcddcfc1a20a04cda size: 2837

Verify the image in the docker hub site

Tags:

Amazon Web Service | Azure Native DevOps | Docker | Microsoft Azure Services

How to build a custom docker image?

by XDK 25. August 2019 16:28

Explanation:

Let's build a custom image of a java web application which runs on Tomcat8

Create a directory named "HelloWorld" under opt to download HelloWorld.war

ubuntu@ip-172-31-59-138:~$ sudo mkdir /opt/HelloWorld
ubuntu@ip-172-31-59-138:~$ cd /opt/HelloWorld
ubuntu@ip-172-31-59-138:/opt/HelloWorld$ sudo wget https://storage.googleapis.com/skl-training/aws-codelabs/aws-intro/HelloWorld.war
--2019-08-24 13:52:00-- https://storage.googleapis.com/skl-training/aws-codelabs/aws-intro/HelloWorld.war
Resolving storage.googleapis.com (storage.googleapis.com)... 172.217.15.112, 2607:f8b0:4004:814::2010
Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.15.112|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9852807 (9.4M) [application/octet-stream]
Saving to: ‘HelloWorld.war’

HelloWorld.war 100%[===================>] 9.40M --.-KB/s in 0.1s

2019-08-24 13:52:00 (91.5 MB/s) - ‘HelloWorld.war’ saved [9852807/9852807]

Note: HelloWorld.war can be downloaded from https://storage.googleapis.com/skl-training/aws-codelabs/aws-intro/HelloWorld.war

Create a dockerfile in /opt/HelloWorld to build the image. (What is a dockerfile?)

#******************************************************************************
#Author - J. Xavier Dilip Kumar
#This is the dockerfile o create HelloWorld image
#******************************************************************************

# The FROM instruction sets the Base Image for subsequent instructions.
# As such, a valid Dockerfile must have FROM as its first instruction.
#
# FROM <image>[:<tag>|@<digest]

FROM tomcat:jre8

# The MAINTAINER instruction allows you to set the Author field of the
# generated images.
#
# MAINTAINER <name>
MAINTAINER XDK

# The LABEL instruction adds metadata to an image. A LABEL is a key-value
# pair. To include spaces within a LABEL value, use quotes and blackslashes
# as you would in command-line parsing.
#
# LABEL <key>=<value> <key>=<value> <key>=<value> ...

LABEL com.company.key="XDK_Company"

# The COPY instruction copies new files or directories from <src> and adds
# them to the filesystem of the container at the path <dest>.
#
# COPY <src>... <dest>
# COPY ["<src>"... "<dest>"] (this form is required for paths containing
# whitespace)

COPY HelloWorld.war /usr/local/tomcat/webapps/

#******************************************************************************

Command to build the custom image

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker build -t xdk_helloworld .
Sending build context to Docker daemon 9.857MB
Step 1/4 : FROM tomcat:jre8
jre8: Pulling from library/tomcat
c5e155d5a1d1: Pull complete
221d80d00ae9: Pull complete
4250b3117dca: Pull complete
d1370422ab93: Pull complete
deb6b03222ca: Pull complete
9cdea8d70cc3: Pull complete
968505be14db: Pull complete
04b5c270ac81: Pull complete
301d76fcab1f: Pull complete
57ca7a0b9e79: Pull complete
3c1d6826d7a3: Pull complete
Digest: sha256:7cdf9dca1472da80e7384403c57b0632753a3a5cdf4f310fc39462e08af8ef39
Status: Downloaded newer image for tomcat:jre8
---> 3639174793ba
Step 2/4 : MAINTAINER XDK
---> Running in de32f3a0cc74
Removing intermediate container de32f3a0cc74
---> d9afcbf0e67e
Step 3/4 : LABEL com.company.key="XDK_Company"
---> Running in f709a079d952
Removing intermediate container f709a079d952
---> 843040213d62
Step 4/4 : COPY HelloWorld.war /usr/local/tomcat/webapps/
---> df98878e7bdf
Successfully built df98878e7bdf
Successfully tagged xdk_helloworld:latest

Verify the image.

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xdk_helloworld latest a801afaa1782 20 seconds ago 473MB
tomcat jre8 3639174793ba 3 months ago 463MB

Command to run the xdk_helloworld docker image, to listen to the port 80 and route to 8080 in the container which is the tomcat's default port 8080 at runtime.

ubuntu@ip-172-31-59-138:/opt/HelloWorld$ docker run -p 80:8080 xdk_helloworld
24-Aug-2019 14:34:03.460 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server ersion: Apache Tomcat/8.5.41
24-Aug-2019 14:34:03.464 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server uilt: May 4 2019 09:17:16 UTC
24-Aug-2019 14:34:03.465 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server umber: 8.5.41.0
24-Aug-2019 14:34:03.465 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name Linux
24-Aug-2019 14:34:03.465 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Verson: 4.15.0-1044-aws
24-Aug-2019 14:34:03.466 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architeture: amd64
24-Aug-2019 14:34:03.467 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Hoe: /usr/lib/jvm/java-8-openjdk-amd64/jre
24-Aug-2019 14:34:03.467 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Verion: 1.8.0_212-8u212-b01-1~deb9u1-b01
24-Aug-2019 14:34:03.468 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Venor: Oracle Corporation
24-Aug-2019 14:34:03.479 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALIN_BASE: /usr/local/tomcat
24-Aug-2019 14:34:03.480 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALIN_HOME: /usr/local/tomcat
24-Aug-2019 14:34:03.480 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
24-Aug-2019 14:34:03.481 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
24-Aug-2019 14:34:03.481 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Djdk.tls.ephemeralDHKeySize=2048
24-Aug-2019 14:34:03.482 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
24-Aug-2019 14:34:03.482 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
24-Aug-2019 14:34:03.483 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Dignore.endorsed.dirs=
24-Aug-2019 14:34:03.483 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Dcatalina.base=/usr/local/tomcat
24-Aug-2019 14:34:03.484 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Dcatalina.home=/usr/local/tomcat
24-Aug-2019 14:34:03.485 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Commandline argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
24-Aug-2019 14:34:03.485 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent oaded APR based Apache Tomcat Native library [1.2.21] using APR version [1.5.2].
24-Aug-2019 14:34:03.486 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent PR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
24-Aug-2019 14:34:03.486 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent PR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
24-Aug-2019 14:34:03.511 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OenSSL successfully initialized [OpenSSL 1.1.0j 20 Nov 2018]
24-Aug-2019 14:34:03.747 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing Protocolandler ["http-nio-8080"]
24-Aug-2019 14:34:03.781 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector sing a shared selector for servlet write/read
24-Aug-2019 14:34:03.813 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing Protocolandler ["ajp-nio-8009"]
24-Aug-2019 14:34:03.814 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector sing a shared selector for servlet write/read
24-Aug-2019 14:34:03.822 INFO [main] org.apache.catalina.startup.Catalina.load Initialization procssed in 1289 ms
24-Aug-2019 14:34:03.868 INFO [main] org.apache.catalina.core.StandardService.startInternal Startig service [Catalina]
24-Aug-2019 14:34:03.869 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Startin Servlet Engine: Apache Tomcat/8.5.41
24-Aug-2019 14:34:03.920 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploWAR Deploying web application archive [/usr/local/tomcat/webapps/HelloWorld.war]

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.1.RELEASE)

2019-08-24 14:34:07.656 INFO 1 --- [ost-startStop-1] app.Application : Sarting Application v1 on 07d453022167 with PID 1 (/usr/local/tomcat/webapps/HelloWorld/WEB-INF/clases started by root in /usr/local/tomcat)
2019-08-24 14:34:07.680 INFO 1 --- [ost-startStop-1] app.Application : N active profile set, falling back to default profiles: default
2019-08-24 14:34:07.771 INFO 1 --- [ost-startStop-1] ationConfigEmbeddedWebApplicationContext : Rfreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6827b7a: startup date [Sat Aug 24 14:34:07 UTC 2019]; root of context hierarchy
2019-08-24 14:34:09.729 INFO 1 --- [ost-startStop-1] trationDelegate$BeanPostProcessorChecker : Ban 'org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration' of type [class rg.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration] is not eligible for etting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-24 14:34:09.936 INFO 1 --- [ost-startStop-1] trationDelegate$BeanPostProcessorChecker : Ban 'validator' of type [class org.springframework.validation.beanvalidation.LocalValidatorFactoryBan] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible forauto-proxying)
2019-08-24 14:34:10.019 INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader : Rot WebApplicationContext: initialization completed in 2248 ms
2019-08-24 14:34:10.982 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mpping servlet: 'dispatcherServlet' to [/]
2019-08-24 14:34:10.984 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mpping filter: 'errorPageFilter' to: [/*]
2019-08-24 14:34:10.985 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mpping filter: 'characterEncodingFilter' to: [/*]
2019-08-24 14:34:10.986 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mpping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-08-24 14:34:10.986 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mpping filter: 'httpPutFormContentFilter' to: [/*]
2019-08-24 14:34:10.986 INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mpping filter: 'requestContextFilter' to: [/*]
2019-08-24 14:34:11.947 INFO 1 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerAdapter : Loking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebpplicationContext@6a827b7a: startup date [Sat Aug 24 14:34:07 UTC 2019]; root of context hierarchy
2019-08-24 14:34:12.145 INFO 1 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mpped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView or.springframework.boot.autoconfigure.web.BasicErrorController.errorHtm

l(javax.servlet.http.HttpServetRequest,javax.servlet.http.HttpServletResponse)
2019-08-24 14:34:12.150 INFO 1 --- [ost-startStop-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mpped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.Strig, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.ervlet.http.HttpServletRequest)
2019-08-24 14:34:12.234 INFO 1 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mpped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.RsourceHttpRequestHandler]
2019-08-24 14:34:12.235 INFO 1 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mpped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHtpRequestHandler]
2019-08-24 14:34:12.332 INFO 1 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mpped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resoure.ResourceHttpRequestHandler]
2019-08-24 14:34:12.664 INFO 1 --- [ost-startStop-1] o.s.j.e.a.AnnotationMBeanExporter : Rgistering beans for JMX exposure on startup
2019-08-24 14:34:12.694 INFO 1 --- [ost-startStop-1] app.Application : Lsting the beans provided by Spring Boot
2019-08-24 14:34:12.695 INFO 1 --- [ost-startStop-1] app.Application : Al initializations completed. App started.
2019-08-24 14:34:12.697 INFO 1 --- [ost-startStop-1] app.Application : Sarted Application in 6.196 seconds (JVM running for 10.827)
2019-08-24 14:34:12.849 INFO 1 --- [ost-startStop-1] org.apache.jasper.servlet.TldScanner : A least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger fo a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs uring scanning can improve startup time and JSP compilation time.
24-Aug-2019 14:34:12.906 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploWAR Deployment of web application archive [/usr/local/tomcat/webapps/HelloWorld.war] has finished n [8,984] ms
24-Aug-2019 14:34:12.911 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
24-Aug-2019 14:34:12.960 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finshed in [49] ms
24-Aug-2019 14:34:12.961 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
24-Aug-2019 14:34:13.003 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in[42] ms
24-Aug-2019 14:34:13.009 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
24-Aug-2019 14:34:13.034 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in[25] ms
24-Aug-2019 14:34:13.035 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
24-Aug-2019 14:34:13.076 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finishedin [40] ms
24-Aug-2019 14:34:13.076 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
24-Aug-2019 14:34:13.395 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deploDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finishe in [318] ms
24-Aug-2019 14:34:13.400 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHanler ["http-nio-8080"]
24-Aug-2019 14:34:13.438 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHanler ["ajp-nio-8009"]
24-Aug-2019 14:34:13.466 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 643 ms
2019-08-24 14:54:19.868 INFO 1 --- [nio-8080-exec-6] app.Application : Request received by index.jsp
2019-08-24 14:54:19.970 INFO 1 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2019-08-24 14:54:20.027 INFO 1 --- [nio-8080-exec-5] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 57 ms

Open http://34.204.171.134/HelloWorld/ in a browser to see the HelloWorld web is application running.

Tags:

Amazon Web Service | Azure Native DevOps | Docker | Microsoft Azure Services

Working with Docker Images

by XDK 25. August 2019 13:42

Command to run a busybox docker image

ubuntu@ip-172-31-59-138:~$ docker run --rm busybox:latest /bin/echo "Hello world"
Unable to find image 'busybox:latest' locally
latest: Pulling from library/busybox
ee153a04d683: Pull complete
Digest: sha256:9f1003c480699be56815db0f8146ad2e22efea85129b5b5983d0e0fb52d9ab70
Status: Downloaded newer image for busybox:latest
Hello world

Note:
clean up (--rm) By default a container’s file system persists even after the container exits. This makes debugging a lot easier (since you can inspect the final state) and you retain all your data by default. But if you are running short-term foreground processes, these container file systems can really pile up. If instead you’d like Docker to automatically clean up the container and remove the file system when the container exits, you can add the --rm flag:

Command to run a tomcat:jre8 docker image and change the container to listen to port 80 instead of tomcat's default port 8080 at runtime.

ubuntu@ip-172-31-59-138:~$ docker run -d -p 80:8080 tomcat:jre8
Unable to find image 'tomcat:jre8' locally
jre8: Pulling from library/tomcat
c5e155d5a1d1: Pull complete
221d80d00ae9: Pull complete
4250b3117dca: Pull complete
d1370422ab93: Pull complete
deb6b03222ca: Pull complete
9cdea8d70cc3: Pull complete
968505be14db: Pull complete
04b5c270ac81: Pull complete
301d76fcab1f: Pull complete
57ca7a0b9e79: Pull complete
3c1d6826d7a3: Pull complete
Digest: sha256:7cdf9dca1472da80e7384403c57b0632753a3a5cdf4f310fc39462e08af8ef39
Status: Downloaded newer image for tomcat:jre8
59cb47cef38dd64376188c66e6dbe7288840e6e68703548c12d1cdf7018f7f9d

Note: In the above command, -d will detach our terminal, -P will publish all exposed ports to random ports

 

Command to verify the java version in the container.

ubuntu@ip-172-31-59-138:~$ docker exec -it 59cb47cef38d java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1~deb9u1-b01)
OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode)

Note: -i Keep STDIN open even if not attached.-t Allocate a pseudo-TTY (Text Only Console).


Command to stop the container

ubuntu@ip-172-31-59-138:~$ docker stop 59cb47cef38d
59cb47cef38d
ubuntu@ip-172-31-59-138:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Command to remove docker container

ubuntu@ip-172-31-59-138:~$ docker rm 59cb47cef38d
59cb47cef38d
ubuntu@ip-172-31-59-138:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

Command to list the docker images

ubuntu@ip-172-31-59-138:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest db8ee88ad75f 5 weeks ago 1.22MB
tomcat jre8 3639174793ba 3 months ago 463MB

Command to remove docker image

ubuntu@ip-172-31-59-138:~$ docker rmi 3639174793ba
Untagged: tomcat:jre8
Untagged: tomcat@sha256:7cdf9dca1472da80e7384403c57b0632753a3a5cdf4f310fc39462 e08af8ef39
Deleted: sha256:3639174793bafbf0f22aeaf6096842f563de3154fe7c756d04966eca1fe4e5 5d
Deleted: sha256:ad683ea82dd8cc2ea298e08626031a01b3bf94a35714572774405f04daa0fe a8
Deleted: sha256:c43fe4301f09c132eefa0707afd2995ade93975a3a7cd11c7ba61b616b5c59 e2
Deleted: sha256:4abee72d794e2aedaa1fd461440964ec8306780c9e22b7b363e953730613e1 45
Deleted: sha256:5f01074ca9f442239d769dffd326dc5004d8bda0365a4767fff8af8e5f58ee 41
Deleted: sha256:fc82c5f00299a2e87402e3090f53e161801b9c6aa6c86121c36e7bb277c68c d0
Deleted: sha256:067619b0ac688892f0e9f086135168006bdc58bc40d902c570772250ea264b 3c
Deleted: sha256:6b6450559d31f9c4e78c7ca449410807188a4d5f88fecb4db7c0f5efbbd9bc 2c
Deleted: sha256:fa14a85b824e4d22bebf8a3787f80f7b13a87e63636efc630416350d3cb09c 8d
Deleted: sha256:a9a9c8853295275070975beba78ec0f573172e6e41b30232a00d8af0d49b8e f3
Deleted: sha256:ddf0293e8e23246803d265b158ffbb9453d925fe392b43515984815853e912 1b
Deleted: sha256:f94641f1fe1f5c42c325652bf55f0513c881c86b620b912b15460e0bca07cc 12

Verify!

ubuntu@ip-172-31-59-138:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest db8ee88ad75f 5 weeks ago 1.22MB

Tags:

Amazon Web Service | Azure Native DevOps | Docker | Microsoft Azure Services

About the author

My name is Xavier Dilip Kumar Jayaraj having 16+ years of IT experience which includes solid experience and depth Knowledge in Application Life Cycle Management, Configuration Management, Implementation and Support using TFS on-premises and Azure DevOps. I have invested in gaining DevOps knowledege to expertise with Cloud Computing providers namely Microsoft Azure and Amazon Web Services in recent years. I am very positive to learn and adapt emerging technologies to client’s environment.

Microsoft Certified: Azure Administrator Associate

Microsoft Certified: Azure DevOps Engineer Expert

DevOps Engineer Certificate Program | Transcript 

OTP-AWSD5: AWS IoT: Developing and Deploying an Internet of Things

[PCEP-30-01] PCEP – Certified Entry-Level Python Programmer

Quotes I Like

"Failure will never overtake me if my determination to succeed is strong enough."  - Dr. APJ. Abdul Kalam

"Always be yourself, express yourself, have faith in yourself, do not go out and look for a successful personality and duplicate it." - Bruce Lee

"Technology is just a tool. In terms of getting the kids working together and motivating them, the teacher is the most important." - Bill Gates

"Innovation distinguishes between a leader and a follower." - Steve Jobs

CategoryList

Disclaimer

The information provided here is based on my expreriences, troubleshooting and online/offline findings. It can be used as is on your own risk without any warranties and I impose no rights.