testcontainers / testcontainers/testcontainers-java
How to make sure there's no stray container not removed when using withDockerfileFromBuilder?
オープン
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 8.7k
- フォーク
- 1.9k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 9
説明
Hi guys,
On XWiki, and since the upgrade to TC 1.15.0 (might not be related but didn't notice it before), I've noticed on our CI agents, that there are some TC-created containers that are not always removed on agents. For example:
These containers are created with the following:
LOGGER.info("(*) Build a dedicated image embedding LibreOffice...");
// The second argument of the ImageFromDockerfile is here to indicate we won't delete the image
// at the end of the test container execution.
container = new XWikiLocalGenericContainer(new ImageFromDockerfile(imageName, false)
.withDockerfileFromBuilder(builder -> {
builder
.from(baseImageName)
.user("root")
.env("LIBREOFFICE_VERSION", officeVersion)
.env("LIBREOFFICE_DOWNLOAD_URL", "https://downloadarchive.documentfoundation.org/"
+ "libreoffice/old/$LIBREOFFICE_VERSION/deb/x86_64/"
+ "LibreOffice_${LIBREOFFICE_VERSION}_Linux_x86-64_deb.tar.gz")
// Note that we expose libreoffice /usr/local/libreoffice so that it can be found by
// JODConverter: https://bit.ly/2w8B82Q
.run("apt-get update && "
+ "apt-get --no-install-recommends -y install curl unzip procps libxinerama1 "
+ "libdbus-glib-1-2 libcairo2 libcups2 libsm6 && "
+ "rm -rf /var/lib/apt/lists/* /var/cache/apt/* && "
+ "wget --no-verbose -O /tmp/libreoffice.tar.gz $LIBREOFFICE_DOWNLOAD_URL && "
+ "mkdir /tmp/libreoffice && "
+ "tar -C /tmp/ -xvf /tmp/libreoffice.tar.gz && "
+ "cd /tmp/LibreOffice_${LIBREOFFICE_VERSION}_Linux_x86-64_deb/DEBS && "
+ "dpkg -i *.deb && "
+ "ln -fs `ls -d /opt/libreoffice*` /opt/libreoffice")
// Increment the image version whenever a change is brought to the image so that it can
// reconstructed on all machines needing it.
.label(OFFICE_IMAGE_VERSION_LABEL, imageVersion);
if (this.testConfiguration.getServletEngine() == ServletEngine.JETTY) {
// Create the right jetty user directory since it doesn't exist
builder.run("mkdir -p /home/jetty && chown jetty:jetty /home/jetty")
// Put back the user as jetty since it's a best practice to not execute the container as
// root.
.user("jetty");
}
builder.build();
}));
Would you have any idea what could be happening and what we could do?
Thanks a lot
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ServletContainerExecutor.java の 286 行目付近から始め、issue に示されている withDockerfileFromBuilder の使用箇所を追跡します。参照されているコンテナを使って CI-agent のシナリオを再現し、Testcontainers のクリーンアップ動作を調査します。作成されたコンテナが残る理由を特定し、検証済みのクリーンアップ修正を文書化または実装できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- docker, java
- 領域
- devops, testing
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100