Friday, October 26, 2018

Using Docker containers to develop microservices



Adam Bien - Thin WARs, Java EE 7, Docker and Productivity
https://www.youtube.com/watch?v=5N4EUDhrkec

Adam Bien - samples
https://github.com/AdamBien/docklands


OpenLiberty MicroService Docker guide
https://openliberty.io/guides/docker.html

GitHub repo https://github.com/OpenLiberty/guide-docker

  mvn clean install


[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:RELEASE:zip.
[INFO] CWWKM2102I: Using installDirectory : /git/guide-docker/finish/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2185I: The liberty-maven-plugin configuration parameter "appsDirectory" value defaults to "dropins".
[INFO] Installing assembly...
[INFO] Expanding: /home/centos/.m2/io/openliberty/openliberty-runtime/18.0.0.3/openliberty-runtime-18.0.0.3.zip into /git/guide-docker/finish/target/liberty
[INFO]
[INFO] --- liberty-maven-plugin:2.6.1:create-server (create-server) @ rest ---
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:RELEASE:zip.
[INFO] CWWKM2102I: Using installDirectory : /git/guide-docker/finish/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2185I: The liberty-maven-plugin configuration parameter "appsDirectory" value defaults to "dropins".
[INFO] CWWKM2112I: Re-using previously installed assembly.
[INFO] CWWKM2143I: Server defaultServer does not exist. Now creating...
[INFO] CWWKM2001I: server.config.dir is /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2001I: server.output.dir is /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2001I: Invoke command is [/git/guide-docker/finish/target/liberty/wlp/bin/server, create, defaultServer].
[INFO] Server defaultServer created.
[INFO] CWWKM2129I: Server defaultServer has been created at /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] Copying 1 file to /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /git/guide-docker/finish/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO]
[INFO] --- maven-war-plugin:3.2.2:war (default-war) @ rest ---
[INFO] Packaging webapp
[INFO] Assembling webapp [rest] in [/git/guide-docker/finish/target/rest-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/git/guide-docker/finish/src/main/webapp]
[INFO] Webapp assembled in [47 msecs]
[INFO] Building war: /git/guide-docker/finish/target/rest-1.0-SNAPSHOT.war
[INFO]
[INFO] --- liberty-maven-plugin:2.6.1:install-apps (install-app) @ rest ---
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:RELEASE:zip.
[INFO] CWWKM2102I: Using installDirectory : /git/guide-docker/finish/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] Copying 1 file to /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /git/guide-docker/finish/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO] CWWKM2160I: Installing application /git/guide-docker/finish/target/rest-1.0-SNAPSHOT.war.
[INFO] Copying 1 file to /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer/apps
[INFO]
[INFO] --- liberty-maven-plugin:2.6.1:test-start-server (start-server) @ rest ---
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:RELEASE:zip.
[INFO] CWWKM2102I: Using installDirectory : /git/guide-docker/finish/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : defaultServer.
[INFO] CWWKM2102I: Using serverDirectory : /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2112I: Re-using previously installed assembly.
[INFO] Copying 1 file to /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer
[INFO] CWWKM2144I: Update server configuration file server.xml from /git/guide-docker/finish/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO] CWWKM2001I: server.config.dir is /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2001I: server.output.dir is /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer.
[INFO] CWWKM2001I: Invoke command is [/git/guide-docker/finish/target/liberty/wlp/bin/server, start, defaultServer].
[INFO] Starting server defaultServer.
[INFO] Server defaultServer started with process ID 20700.
[INFO] Waiting up to 30 seconds for server confirmation:  CWWKF0011I to be found in /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer/logs/messages.log
[INFO] CWWKM2010I: Searching for CWWKF0011I in /git/guide-docker/finish/target/liberty/wlp/usr/servers/defaultServer/logs/messages.log. This search will timeout after 30 seconds.
[INFO] CWWKM2015I: Match number: 1 is [10/26/18 13:21:13:991 CEST] 00000019 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The server defaultServer is ready to run a smarter planet..



 yum install docker

sudo systemctl start docker
 
Configure Docker proxy 
 https://docs.docker.com/config/daemon/systemd/#httphttps-proxy

docker build -t ol-runtime .


docker build -t ol-runtime .
Sending build context to Docker daemon 150.5 MB
Step 1/4 : FROM open-liberty
Trying to pull repository docker.io/library/open-liberty ...
latest: Pulling from docker.io/library/open-liberty
18d680d61657: Pull complete
0addb6fece63: Pull complete
78e58219b215: Pull complete
eb6959a66df2: Pull complete
d28276d78514: Pull complete
f4b7f9cac3ff: Pull complete
cca6875781ba: Pull complete
19927b6c1502: Pull complete
e7b4b52f440a: Pull complete
b756387f6847: Pull complete
Digest: sha256:ed0252357b07d199c18fa67eac13a563cef9d052c856f7050727775bf2dc3e2b
Status: Downloaded newer image for docker.io/open-liberty:latest
 ---> 2408c7bfb52d
Step 2/4 : RUN ln -s /opt/ol/wlp/usr/servers /servers
 ---> Running in ee3238c49602

 ---> b99f07819d6b
Removing intermediate container ee3238c49602
Step 3/4 : ENTRYPOINT /opt/ol/wlp/bin/server run
 ---> Running in eb0103bfe0a0
 ---> 5be83f0c9bcd
Removing intermediate container eb0103bfe0a0
Step 4/4 : CMD defaultServer
 ---> Running in 79167390de6a
 ---> 026f9cdf87b7
Removing intermediate container 79167390de6a
Successfully built 026f9cdf87b7


Run container

$ docker run -d --name rest-app -p 9080:9080 -p 9443:9443 -v /git/guide-maven-intro/finish/target/liberty/wlp/usr/servers:/servers ol-runtime
6177bbf6b6626c4004878910f97bf2581d7f16cc4aca46550685e65b06a1771b



 docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                       PORTS               NAMES
6177bbf6b662        ol-runtime          "/opt/ol/wlp/bin/s..."   54 seconds ago      Exited (23) 52 seconds ago                       rest-app



No comments:

Post a Comment