CLOVER🍀

That was when it all began.

簡単にUbuntu Linux仮想マシンを起動できる、multipassを試す

これは、なにをしたくて書いたもの?

少し前に、Ubuntu Linux仮想マシンを起動できる、multipassというものを知りまして。

Multipass orchestrates virtual Ubuntu instances

第590回 Windows/macOS/Linuxで使える仮想マシン管理ツール『multipass』:Ubuntu Weekly Recipe|gihyo.jp … 技術評論社

multipass

Ubuntu Linuxの開発元である、Canonicalが開発している、LinuxWindows MacOSで使うことができる仮想マシン管理ツールです。

特徴は、以下の通り。

  • Linuxインスタンスを起動、管理することができる、CLIを提供
  • Ubuntu Linux LTSが利用可能
  • clound-initを利用した初期化が可能
  • バックエンドに、仮想化技術(Hyper-VKVMなど)を利用
  • ホスト側とファイル共有が可能

また、X-Window Systemを使いたい場合や、Ubuntu Linux以外のOSを使いたい場合には、multipassは適しません。その他の仮想化ツールを
使いましょう。

ドキュメントは、こちらです。

Multipass Documentation outline | Multipass documentation

バックエンドに使う仮想化技術としては、それぞれ以下のようです。

それでは、使ってみましょう。

環境

今回の環境は、こちら。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:    18.04
Codename:   bionic

Ubuntu Linux 18.04 LTSを使います。

multipassを使う

インストール

インストールは、snapで。

$ sudo snap install multipass --classic

インストールされたmultipassのバージョンは、こちら。

$ multipass version
multipass  1.0.2
ヘルプを見る

multipassのヘルプを見てみます。

$ multipass help
Usage: multipass [options] <command>
Create, control and connect to Ubuntu instances.

This is a command line utility for multipass, a
service that manages Ubuntu instances.

Options:
  -h, --help     Display this help
  -v, --verbose  Increase logging verbosity, repeat up to three times for more
                 detail

Available commands:
  delete    Delete instances
  exec      Run a command on an instance
  find      Display available images to create instances from
  get       Get a configuration setting
  help      Display help about a command
  info      Display information about instances
  launch    Create and start an Ubuntu instance
  list      List all available instances
  mount     Mount a local directory in the instance
  purge     Purge all deleted instances permanently
  recover   Recover deleted instances
  restart   Restart instances
  set       Set a configuration setting
  shell     Open a shell on a running instance
  start     Start instances
  stop      Stop running instances
  suspend   Suspend running instances
  transfer  Transfer files between the host and instances
  umount    Unmount a directory from an instance
  version   Show version details

コマンドを見ると、およそ使い方がわかりますね。

「help」の後にコマンドを入力するか、コマンドに「--help」を付けると、そのコマンドに絞ったヘルプを見ることができます。

$ sudo multipass help find
## または
$ sudo multipass find --help
Usage: multipass find [options] [<remote:>][<string>]
Lists available images matching <string> for creating instances from.
With no search string, lists all aliases for supported Ubuntu releases.

Options:
  -h, --help          Display this help
  -v, --verbose       Increase logging verbosity, repeat up to three times for
                      more detail
  --show-unsupported  Show unsupported cloud images as well
  --format <format>   Output list in the requested format.
                      Valid formats are: table (default), json, csv and yaml

Arguments:
  string              An optional value to search for in [<remote:>]<string>
                      format, where <remote> can be either ‘release’ or ‘daily’.
                      If <remote> is omitted, it will search ‘release‘ first,
                      and if no matches are found, it will then search ‘daily‘.
                      <string> can be a partial image hash or an Ubuntu release
                      version, codename or alias.
利用できる仮想マシンのイメージを探す

「find」を使用します。

$ sudo multipass find
Image                   Aliases           Version          Description
snapcraft:core          core16            20200131         Snapcraft builder for Core 16
snapcraft:core18                          20200131         Snapcraft builder for Core 18
core                    core16            20190806         Ubuntu Core 16
core18                                    20190806         Ubuntu Core 18
16.04                   xenial            20200129         Ubuntu 16.04 LTS
18.04                   bionic,lts        20200129.1       Ubuntu 18.04 LTS
19.10                   eoan              20200129         Ubuntu 19.10
daily:20.04             devel,focal       20200206         Ubuntu 20.04 LTS

Ubuntu Linux LTSがずらっと並びますね。Ubuntu Coreも使えるようです。

`multipass find` command | Multipass documentation

Unsupportedなものも見ることができます。

$ sudo multipass find --show-unsupported
Image                   Aliases           Version          Description
snapcraft:core          core16            20200131         Snapcraft builder for Core 16
snapcraft:core18                          20200131         Snapcraft builder for Core 18
core                    core16            20190806         Ubuntu Core 16
core18                                    20190806         Ubuntu Core 18
10.04                   lucid             20150427         Ubuntu 10.04 LTS
11.10                   oneiric           20130509         Ubuntu 11.10
12.04                   precise           20170502         Ubuntu 12.04 LTS
12.10                   quantal           20140409         Ubuntu 12.10
13.04                   raring            20140111         Ubuntu 13.04
13.10                   saucy             20140709         Ubuntu 13.10
14.04                   trusty            20191107         Ubuntu 14.04 LTS
14.10                   utopic            20150723         Ubuntu 14.10
15.04                   vivid             20160203         Ubuntu 15.04
15.10                   wily              20160715         Ubuntu 15.10
16.04                   xenial            20200129         Ubuntu 16.04 LTS
16.10                   yakkety           20170719         Ubuntu 16.10
17.04                   zesty             20171208         Ubuntu 17.04
17.10                   artful            20180706         Ubuntu 17.10
18.04                   bionic,lts        20200129.1       Ubuntu 18.04 LTS
18.10                   cosmic            20190628         Ubuntu 18.10
19.04                   disco             20200109         Ubuntu 19.04
19.10                   eoan              20200129         Ubuntu 19.10
daily:20.04             devel,focal       20200206         Ubuntu 20.04 LTS
仮想マシンの取得と起動

仮想マシンの起動と取得を同時に行うには、「launch」コマンドを使用します。ヘルプを見ると、指定できそうなものがいろいろ
わかりますね。

$ multipass launch --help
Usage: multipass launch [options] [[<remote:>]<image> | <url>]
Create and start a new instance.

Options:
  -h, --help           Display this help
  -v, --verbose        Increase logging verbosity, repeat up to three times for
                       more detail
  -c, --cpus <cpus>    Number of CPUs to allocate.
                       Minimum: 1, default: 1.
  -d, --disk <disk>    Disk space to allocate. Positive integers, in bytes, or
                       with K, M, G suffix.
                       Minimum: 512M, default: 5G.
  -m, --mem <mem>      Amount of memory to allocate. Positive integers, in
                       bytes, or with K, M, G suffix.
                       Minimum: 128M, default: 1G.
  -n, --name <name>    Name for the instance. If it is 'primary' (the
                       configured primary instance name), the user's home
                       directory is mounted inside the newly launched instance,
                       in 'Home'.
  --cloud-init <file>  Path to a user-data cloud-init configuration, or '-' for
                       stdin

Arguments:
  image                Optional image to launch. If omitted, then the default
                       Ubuntu LTS will be used.
                       <remote> can be either ‘release’ or ‘daily‘. If <remote>
                       is omitted, ‘release’ will be used.
                       <image> can be a partial image hash or an Ubuntu release
                       version, codename or alias.
                       <url> is a custom image URL that is in http://, https://,
                       or file:// format.

`multipass launch` command | Multipass documentation

ディスクサイズが指定できるのは、個人的に嬉しかったりします…。

仮想マシンは、デフォルトではUbuntu LTSが使われるようです。

とりあえず、起動してみましょう。

$ sudo multipass launch                                     
Launched: uplifting-whipsnake

Vagrantよりは、ちょっと時間がかかりますね。

「uplifting-whipsnake」というのは、起動したインスタンスの名前です。

バージョンを確認してみましょう。

$ sudo multipass exec uplifting-whipsnake -- lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic

Ubuntu Linux 18.04 LTSですね。

今度は、仮想マシンのイメージと、インスタンス名を指定してみます。

$ sudo multipass launch --name my-instance 18.04
インスタンスにログインする

「shell」を使います。

$ sudo multipass shell my-instance
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-76-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Fri Feb  7 07:39:11 PST 2020

  System load:  0.0               Processes:           83
  Usage of /:   20.9% of 4.67GB   Users logged in:     0
  Memory usage: 11%               IP address for ens4: 10.209.91.178
  Swap usage:   0%


0 packages can be updated.
0 updates are security updates.


Last login: Fri Feb  7 07:38:16 2020 from 10.209.91.1

`multipass shell` command | Multipass documentation

ログイン後は、ふつうにコマンドなどが使えます。

ubuntu@my-instance:~$ ll
total 36
drwxr-xr-x 5 ubuntu ubuntu 4096 Feb  7 07:39 ./
drwxr-xr-x 3 root   root   4096 Feb  7 07:33 ../
-rw------- 1 ubuntu ubuntu   15 Feb  7 07:39 .bash_history
-rw-r--r-- 1 ubuntu ubuntu  220 Apr  4  2018 .bash_logout
-rw-r--r-- 1 ubuntu ubuntu 3771 Apr  4  2018 .bashrc
drwx------ 2 ubuntu ubuntu 4096 Feb  7 07:33 .cache/
drwx------ 3 ubuntu ubuntu 4096 Feb  7 07:33 .gnupg/
-rw-r--r-- 1 ubuntu ubuntu  807 Apr  4  2018 .profile
drwx------ 2 ubuntu ubuntu 4096 Feb  7 07:33 .ssh/
-rw-r--r-- 1 ubuntu ubuntu    0 Feb  7 07:38 .sudo_as_admin_successful
インスタンスに対して、コマンドを実行する

「exec」を使います。

$ sudo multipass exec my-instance ls /
bin  boot  dev  etc  home  initrd.img  initrd.img.old  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var  vmlinuz  vmlinuz.old

実行するコマンドにオプションが必要な場合は、「--」を付与します。

$ sudo multipass exec my-instance -- ls -l /
total 80
drwxr-xr-x   2 root root  4096 Jan 29 13:18 bin
drwxr-xr-x   4 root root  4096 Jan 29 13:18 boot
drwxr-xr-x  16 root root  3740 Feb  7 07:32 dev
drwxr-xr-x  89 root root  4096 Feb  7 07:33 etc
drwxr-xr-x   3 root root  4096 Feb  7 07:33 home
lrwxrwxrwx   1 root root    33 Jan 29 13:16 initrd.img -> boot/initrd.img-4.15.0-76-generic
lrwxrwxrwx   1 root root    33 Jan 29 13:16 initrd.img.old -> boot/initrd.img-4.15.0-76-generic
drwxr-xr-x  20 root root  4096 Jan 29 13:16 lib
drwxr-xr-x   2 root root  4096 Jan 29 13:15 lib64
drwx------   2 root root 16384 Jan 29 13:18 lost+found
drwxr-xr-x   2 root root  4096 Jan 29 13:15 media
drwxr-xr-x   2 root root  4096 Jan 29 13:15 mnt
drwxr-xr-x   2 root root  4096 Jan 29 13:15 opt
dr-xr-xr-x 103 root root     0 Feb  7 07:32 proc
drwx------   3 root root  4096 Feb  7 07:33 root
drwxr-xr-x  24 root root   840 Feb  7 07:34 run
drwxr-xr-x   2 root root  4096 Jan 29 13:17 sbin
drwxr-xr-x   2 root root  4096 Feb  7 07:33 snap
drwxr-xr-x   2 root root  4096 Jan 29 13:15 srv
dr-xr-xr-x  13 root root     0 Feb  7 07:32 sys
drwxrwxrwt   9 root root  4096 Feb  7 07:33 tmp
drwxr-xr-x  10 root root  4096 Jan 29 13:15 usr
drwxr-xr-x  13 root root  4096 Jan 29 13:17 var
lrwxrwxrwx   1 root root    30 Jan 29 13:16 vmlinuz -> boot/vmlinuz-4.15.0-76-generic
lrwxrwxrwx   1 root root    30 Jan 29 13:16 vmlinuz.old -> boot/vmlinuz-4.15.0-76-generic

「shell」とは違って、一時的にコマンドを実行するだけです。

`multipass exec` command | Multipass documentation

現在のインスタンスの一覧を見る

「list」を使います。

$ sudo multipass list          
Name                    State             IPv4             Image
my-instance             Running           10.209.91.178    Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS

`multipass list` command | Multipass documentation

インスタンスの起動、停止、サスペンドを行う

それぞれ、「start」、「stop」、「suspend」です。

停止。

$ sudo multipass stop my-instance


$ sudo multipass list
Name                    State             IPv4             Image
my-instance             Stopped           --               Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS

起動。

$ sudo multipass start my-instance


$ sudo multipass list 
Name                    State             IPv4             Image
my-instance             Running           10.209.91.178    Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS

サスペンド

$ sudo multipass suspend my-instance


$ sudo multipass list                        
Name                    State             IPv4             Image
my-instance             Suspended         --               Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS

ただ、サスペンドしたら、うまく再開できなくなりました…。

`multipass start` command | Multipass documentation

インスタンスの再起動は、「restart」です。

$ sudo multipass restart my-instance


$ sudo multipass list                         
Name                    State             IPv4             Image
my-instance             Restarting        --               Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS
my-instance3            Running           10.209.91.201    Ubuntu 18.04 LTS
インスタンスの情報を見る

「info」で。

$ sudo multipass info my-instance
Name:           my-instance
State:          Running
IPv4:           10.209.91.127
Release:        Ubuntu 18.04.3 LTS
Image hash:     ae2c9391b71a (Ubuntu 18.04 LTS)
Load:           1.14 0.38 0.13
Disk usage:     1000.6M out of 4.7G
Memory usage:   72.6M out of 985.1M

`multipass info` command | Multipass documentation

インスタンスを削除する

「delete」で、インスタンスを削除することができます。

$ sudo multipass delete my-instance3

ただ、この状態は削除マークが付くだけで、「recover」で復帰させることができます。

$ sudo multipass list 
Name                    State             IPv4             Image
my-instance             Running           10.209.91.127    Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS
my-instance3            Deleted           --               Not Available


$ sudo multipass recover my-instance3


$ sudo multipass list 
Name                    State             IPv4             Image
my-instance             Running           10.209.91.127    Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS
my-instance3            Stopped           --               Ubuntu 18.04 LTS

「delete」したインスタンスを削除するには、「purge」を使います。

$ sudo multipass list 
Name                    State             IPv4             Image
my-instance             Running           10.209.91.127    Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS
my-instance3            Deleted           --               Not Available


$ sudo multipass purge


$ sudo multipass list 
Name                    State             IPv4             Image
my-instance             Running           10.209.91.127    Ubuntu 18.04 LTS
my-instance2            Running           10.209.91.15     Ubuntu 16.04 LTS
ホスト/インスタンス間でファイルをやり取りする

「transfer」でファイルを転送することができます。ディレクトリは転送することができません。

ホスト側でファイルを作成。

$ echo hello > hello.txt

ホストから、インスタンスに転送。転送先のインスタンス名を「:」区切りで指定する必要があります。

$ sudo multipass transfer hello.txt my-instance:/tmp/hello.txt

確認。

$ sudo multipass exec my-instance cat /tmp/hello.txt
hello

また、ホスト側のディレクトリをインスタンス側でマウントすることもできます。

「mount」コマンドを利用します。

マウント対象に、Tomcatを持ってきてみましょう。

$ curl -O https://www-eu.apache.org/dist/tomcat/tomcat-9/v9.0.30/bin/apache-tomcat-9.0.30.tar.gz
$ tar xf apache-tomcat-9.0.30.tar.gz
$ mv apache-tomcat-9.0.30 tomcat

「mount」。

$ sudo multipass mount tomcat my-instance:/tomcat

確認。

$ sudo multipass exec my-instance df
Filesystem             1K-blocks    Used  Available Use% Mounted on
udev                      491608       0     491608   0% /dev
tmpfs                     100876     612     100264   1% /run
/dev/sda1                4901996 1180004    3705608  25% /
tmpfs                     504372       0     504372   0% /dev/shm
tmpfs                       5120       0       5120   0% /run/lock
tmpfs                     504372       0     504372   0% /sys/fs/cgroup
/dev/sda15                106858    3668     103190   4% /boot/efi
tmpfs                     100872       0     100872   0% /run/user/1000
:/home/user/tomcat 1048576000       0 1048576000   0% /tomcat

また、マウント状況は「info」で確認することもできます。

$ sudo multipass info my-instance
Name:           my-instance
State:          Running
IPv4:           10.209.91.127
Release:        Ubuntu 18.04.3 LTS
Image hash:     ae2c9391b71a (Ubuntu 18.04 LTS)
Load:           0.23 0.07 0.02
Disk usage:     1.1G out of 4.7G
Memory usage:   74.8M out of 985.1M
Mounts:         /home/user/tomcat => /tomcat
                    UID map: 0:default
                    GID map: 0:default

「unmount」で、アンマウントを行います。

$ sudo multipass unmount my-instance:/tomcat

まとめ

ざっと、multipassを試してみました。

利用できる仮想マシンUbuntu Linux限定だったり、起動はやや重たいかな?という気はするものの、libvirtVagrantを使っている
自分としては使いやすそうな部分もあったり。

手段として、覚えておきましょう。

Distroless Dockerイメージ(OpenJDK)を試す

これは、なにをしたくて書いたもの?

前々から、DistrolessというDockerイメージが気になっていて、ちょっと試して見ることにしました。

GitHub - GoogleContainerTools/distroless: 🥑 Language focused docker images, minus the operating system.

Base Image Journey 2018 - Speaker Deck

Distroless

Distroless Dockerイメージとは、アプリケーション(というか言語)と、その依存関係のみが含まれるDockerイメージです。

"Distroless" images contain only your application and its runtime dependencies. They do not contain package managers, shells or any other programs you would expect to find in a standard Linux distribution.

その他のプログラムは入っておらず、シェルすらありません。よって、イメージのサイズも小さめです。

どうしてこういったイメージが存在するのかというと、不要なものを極力省くことによって、セキュリティリスクを抑えることが
できるとされています。

Why should I use distroless images?

各言語のベースとなるDockerイメージに、どんなものが含まれているかはこちらに記載があります。

https://github.com/GoogleContainerTools/distroless/tree/master/base

  • ca-certificates
  • /etc/passwd (root only)
  • /tmp directory
  • tzdata
  • glibc
  • libssl
  • openssl

このDockerイメージの使い方としては、シェルが含まれないので、実行対象となるファイルやスクリプトを入れたDockerイメージを作り、
ENTRYPOINTやCMDで実行対象のファイルを指定するようです。

How do I use distroless images?

例えば、Javaであれば以下のように書きます。

CMD ["main.jar"]

https://github.com/GoogleContainerTools/distroless/blob/master/examples/java/Dockerfile

ベースイメージの方では、「java -jar」が指定されています。

Distroless Dockerイメージではアプリケーションのビルドはできないので、ビルドが必要な言語の場合はマルチステージビルドを使って
別のDockerイメージでビルドした結果を使用します。

ベースとなるOSイメージは、Debianのようです。現時点では、Debian 10です。

Base Operating System

各言語のイメージとしては、以下があります。

distroless/examples at master · GoogleContainerTools/distroless · GitHub

今回は、Java(OpenJDK)のイメージを使用してみます。

Distroless(OpenJDK)のDockerイメージ

以下のようにして、まずはDockerイメージを取得してみます。

$  docker image pull gcr.io/distroless/java:latest
$  docker image pull gcr.io/distroless/java:8
$  docker image pull gcr.io/distroless/java:11

確認。

$ docker container run -it --rm gcr.io/distroless/java:latest -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)


$ docker container run -it --rm gcr.io/distroless/java:8 -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)


$ docker container run -it --rm gcr.io/distroless/java:11 -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-post-Debian-1bpo91)
OpenJDK 64-Bit Server VM (build 11.0.5+10-post-Debian-1bpo91, mixed mode)

latestは、JDK 8を指しているようです。細かいバージョンを指定できるタグは…なさそうです。

起動時には「java -jar」を実行しようとするので、シェルを実行することはできません。

$ docker container run -it --rm gcr.io/distroless/java:8 bash
Error: Unable to access jarfile bash

イメージのサイズですが、こんな感じでした。

$ docker image ls | grep distroless
gcr.io/distroless/java             8                   0ca884705e30        50 years ago         125MB
gcr.io/distroless/java             latest              0ca884705e30        50 years ago         125MB
gcr.io/distroless/java             11                  032fa27b8c17        50 years ago         195MB

比較として、OpenJDKのイメージを見てみます。

$ docker image ls | grep openjdk | grep -v none | sort
openjdk                            11-jdk              193af7392c2e        4 days ago          606MB
openjdk                            11-jdk-slim         724512274dbb        4 days ago          401MB
openjdk                            11-jre              67edbda57bd6        4 days ago          267MB
openjdk                            11-jre-slim         fa68260be6bf        4 days ago          204MB
openjdk                            8-jdk               0bfcee65c8ca        4 days ago          488MB
openjdk                            8-jdk-alpine        a3562aa0b991        9 months ago        105MB
openjdk                            8-jdk-slim          4229f5fb33f9        4 days ago          284MB
openjdk                            8-jre               5557c40af992        4 days ago          246MB
openjdk                            8-jre-alpine        f7a292bbb70c        9 months ago        84.9MB
openjdk                            8-jre-slim          9c82c74fbc96        4 days ago          184MB

Alpineほどではないですが、JREに比べるとスリムになりますね。できる限りイメージは小さくしたいけれど、Alpineを避けたい人には
Distroless Dockerイメージは有力な選択肢になるんでしょうね。

インストールされているOpenJDKは、Debianでパッケージ管理されているものみたいです。

https://github.com/GoogleContainerTools/distroless/blob/master/java/BUILD

Quarkusで試す

せっかくなので、Distroless Dockerイメージを使って、自前のイメージを作ってみましょう。

お題は、Quarkusの最小構成でいきます。1.2.0.Finalを使用します。

プロジェクトの作成。

$ curl -o app.zip 'https://code.quarkus.io/d?g=org.example&a=app&v=1.0.0&b=MAVEN&c=org.example.ExampleResource&s=&cn=code.quarkus.io'
$ unzip app.zip

Dockerfileは、こんな感じで作成。
Dockerfile

FROM openjdk:8-jdk-slim AS build-env
ADD ./app /app
WORKDIR /app
RUN ./mvnw package -DskipTests=true

FROM gcr.io/distroless/java:8
COPY --from=build-env /app/target/app-1.0.0-runner.jar /app/app-1.0.0-runner.jar
COPY --from=build-env /app/target/lib /app/lib
WORKDIR /app
CMD ["app-1.0.0-runner.jar"]

こちらを参考にしています。

https://github.com/GoogleContainerTools/distroless/blob/master/examples/java/Dockerfile

ビルド。

$ docker image build -t kazuhira/quarkus-app:latest .

起動。

$ docker container run -it --rm -p 8080:8080 kazuhira/quarkus-app:latest

確認。

$ curl localhost:8080/hello
hello

OKそうですね。

くどいようですが、このイメージを使っても「docker container exec」でそのままではコンテナ内に入ることはできません。

$ docker container exec dazzling_ritchie -it bash
OCI runtime exec failed: exec failed: container_linux.go:346: starting container process caused "exec: \"-it\": executable file not found in $PATH": unknown

これをやりたかったら、BusyBoxを使ったりすることになるでしょう。

とりあえず、こんな感じで。