Liferay カスタム docker イメージの作成方法
written-by
Sivakumar Perumal
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
legacy-article
learn-legacy-article-disclaimer-text
ご覧のページは、お客様の利便性のために一部機械翻訳されています。また、ドキュメントは頻繁に更新が加えられており、翻訳は未完成の部分が含まれることをご了承ください。最新情報は都度公開されておりますため、必ず英語版をご参照ください。翻訳に問題がある場合は、こちら までご連絡ください。
問題
任意のベースイメージを使用してLiferayカスタムdockerイメージを作成する方法は?
Environment
Liferay DXP 7.0, 7.1, 7.2, 7.3, 7.4
Elasticsearch
解決策
カスタムDockerイメージを作成するためには、Dockerfileを作成する必要があります。 Dockerfile は、Docker デーモンがイメージ作成時に呼び出すコマンドのリストを含むテキストファイルです。 Dockerfileには、アプリを実行するためにDockerが必要とするすべての情報(実行するベースDockerイメージ、プロジェクトのコードやファイルの場所、依存関係、スタートアップ時に実行するコマンド)が含まれています。
簡単に言うと、カスタムDockerイメージの作成方法を自動化するための素晴らしい方法です。 一番良いのは、Dockerfileに書く コマンド は、同等のLinuxコマンドとほぼ同じ であることです。 つまり、独自のDockerfileを作成するために新しい構文を学ぶ必要はあまりないのです。
LiferayのカスタムDockerイメージは、以下のDockerfileを使用することができます。
FROM liferay/portal:7.2.0-ga1 COPY $LIFERAY:liferay deploy /mnt/liferay/deploy COPY $LIFERAY:liferay patching /mnt/liferay/patching COPY $LIFERAY:liferay scripts /mnt/liferay/scripts COPY $LIFERAY:liferay configs /home/liferay/configs
Elasticsearchの場合
shiv@1G2BNF2:~/elasticsearch$ cat Dockerfile
FROM elasticsearch:6.5.0
RUN ./bin/elasticsearch-plugin install analysis-icu
RUN ./bin/elasticsearch-plugin install analysis-kuromoji
RUN ./bin/elasticsearch-plugin install analysis-smartcn
RUN ./bin/elasticsearch-plugin install analysis-stempel
shiv@1G2BNF2:~/elasticsearch$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM elasticsearch:6.5.0
6.5.0: Pulling from library/elasticsearch
aeb7866da422: Pull complete
81639a7b2dd2: Pull complete
e19ec3fb86be: Pull complete
da4a438e18a0: Pull complete
a67c58efe429: Pull complete
13fe2c49e9dd: Pull complete
162a1c0b34b0: Pull complete
64d1055a351e: Pull complete
Digest: sha256:81a75d058b2ca52be06915eed43343c4e289d5463265de8446fbd77f8e170327
Status: Downloaded newer image for elasticsearch:6.5.0
---> ff171d17e77c
Step 2/5 : RUN ./bin/elasticsearch-plugin install analysis-icu
---> Running in 0fbc3cd33cbd
-> Downloading analysis-icu from elastic
[=================================================] 100%??
-> Installed analysis-icu
Removing intermediate container 0fbc3cd33cbd
---> ef8929767919
Step 3/5 : RUN ./bin/elasticsearch-plugin install analysis-kuromoji
---> Running in 3db6c4a70d0f
-> Downloading analysis-kuromoji from elastic
[=================================================] 100%??
-> Installed analysis-kuromoji
Removing intermediate container 3db6c4a70d0f
---> c19b8615f72b
Step 4/5 : RUN ./bin/elasticsearch-plugin install analysis-smartcn
---> Running in b5a1b5be8283
-> Downloading analysis-smartcn from elastic
[=================================================] 100%??
-> Installed analysis-smartcn
Removing intermediate container b5a1b5be8283
---> e11b96cb54e8
Step 5/5 : RUN ./bin/elasticsearch-plugin install analysis-stempel
---> Running in 23176fb83dc9
-> Downloading analysis-stempel from elastic
[=================================================] 100%??
-> Installed analysis-stempel
Removing intermediate container 23176fb83dc9
---> afc74f854edc
Successfully built afc74f854edc
shiv@1G2BNF2:~/elasticsearch$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> afc74f854edc 19 minutes ago 795MB
shiv@1G2BNF2:~/elasticsearch$ docker tag afc74f854edc customimage/es:1.0
shiv@1G2BNF2:~/elasticsearch$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
customimage/es 1.0 afc74f854edc 21 minutes ago 795MB
Dockerfileを使用してイメージを構築するために使用される基本的な構文は次のとおりです:
docker build [OPTIONS] PATH | URL | -
したがって、Dockerイメージを構築するには、次のようになります:
docker build [location of your dockerfile]
Dockerfileがあるディレクトリに既にいる場合は、locationの代わりにa.を入れてください:
docker build .
-t フラグを追加することで、新しい画像に名前を付けてタグ付けすることができ、複数の画像を扱うときに便利です:
docker build -t my_first_image .
イメージのビルドに成功したら、そのイメージがローカルイメージのリストにあるかどうかをコマンドで確認することができます:
docker images
追加情報
did-this-article-resolve-your-issue