3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Open LibertyをDockerで使ってみる

Posted at

タイトルの通り、dockerを使ってopen libertyを動かしてみます。以下の人向けです。

  • Open Libertyって聞いたことあるけど、触ったことない人
  • できるだけ面倒な準備なしでlibertyを動かしてみたい人

Open Libertyってなに?

  • 高速で効率的なクラウドネイティブJavaマイクロサービスを構築するための軽量なオープンフレームワークです。
  • 要するにJava製のアプリケーションサーバーです。

前提知識

  • Docker
  • Linuxコマンド
  • 基礎的なWebアプリケーションの知識

環境

  • Windows11 + WSL2(Ubuntu 20.04.5)
  • Dockerインストール済み
  • ブラウザはEdge

動かしてみよう

以下コマンド一発でとりあえず動きます。ちょっと試すにはDockerは便利ですね。

# docker run コマンド
docker run -p 9080:9080 -v ~/Sample1.war:/config/dropins/Sample1.war open-liberty:full

Launching defaultServer (Open Liberty 23.0.0.2/wlp-1.0.74.cl230220230222-1257) on Eclipse OpenJ9 VM, version 1.8.0_362-b09 (en_US)
[AUDIT   ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/keystore.xml
[AUDIT   ] CWWKG0093A: Processing configuration drop-ins resource: /opt/ol/wlp/usr/servers/defaultServer/configDropins/defaults/open-default-port.xml
[WARNING ] CWWKS3103W: There are no users defined for the BasicRegistry configuration of ID com.ibm.ws.security.registry.basic.config[basic].
[AUDIT   ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT   ] CWWKS4104A: LTPA keys created in 0.319 seconds. LTPA key file: /opt/ol/wlp/output/defaultServer/resources/security/ltpa.keys
[AUDIT   ] CWPKI0803A: SSL certificate created in 0.658 seconds. SSL key file: /opt/ol/wlp/output/defaultServer/resources/security/key.p12
[AUDIT   ] CWWKI0001I: The CORBA name server is now available at corbaloc:iiop:localhost:2809/NameService.
[AUDIT   ] CWWKT0016I: Web application available (default_host): http://a9dad3b3af5b:9080/Sample1/
[AUDIT   ] CWWKZ0001I: Application Sample1 started in 0.781 seconds.
[AUDIT   ] CWWKF0012I: The server installed the following features: [appClientSupport-1.0, appSecurity-2.0, appSecurity-3.0, batch-1.0, beanValidation-2.0, cdi-2.0, concurrent-1.0, distributedMap-1.0, ejb-3.2, ejbHome-3.2, ejbLite-3.2, ejbPersistentTimer-3.2, ejbRemote-3.2, el-3.0, j2eeManagement-1.1, jacc-1.5, jaspic-1.1, javaMail-1.6, javaee-8.0, jaxb-2.2, jaxrs-2.1, jaxrsClient-2.1, jaxws-2.2, jca-1.7, jcaInboundSecurity-1.0, jdbc-4.2, jms-2.0, jndi-1.0, jpa-2.2, jpaContainer-2.2, jsf-2.3, jsonb-1.0, jsonp-1.1, jsp-2.3, managedBeans-1.0, mdb-3.2, servlet-4.0, ssl-1.0, wasJmsClient-2.0, wasJmsSecurity-1.0, wasJmsServer-1.0, webProfile-8.0, websocket-1.1].
[AUDIT   ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 3.713 seconds.

コンテナが動いていることを確認

docker container ls
CONTAINER ID   IMAGE               COMMAND                  CREATED          STATUS          PORTS                                                 NAMES
a9dad3b3af5b   open-liberty:full   "/opt/ol/helpers/run…"   47 seconds ago   Up 46 seconds   0.0.0.0:9080->9080/tcp, :::9080->9080/tcp, 9443/tcp   vigorous_lalande

ブラウザでhttp://localhost:9080/にアクセス。トップページが表示されました!簡単ですね。
liberty_top.png

トップページ以外も表示してみよう

以下ファイルを~/Sample1.warに配置します。

index.jsp
<html>
<head><title>test page</title></head>
<body>It is <%= new java.util.Date() %> now!!!</body>
</html>

http://localhost:9080/Sample1/にアクセス。時刻が表示される簡単なページを表示できました!

liberty-time.png

まとめ

dockerを使うとopen libertyをかなーり気楽に試すことができます。みなさんもぜひやってみてください!

参考文献

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?