1
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 3 years have passed since last update.

Dockefileの基本書式

Posted at

Dockerfileで使う基本書式について、簡単にまとめました。
Dockerfileは、docker buildコマンドで、Dockerイメージをビルドするためのテキストファイルです。

基本記述書式

書式 説明
FROM <image> Docker imageのベースとなるDocker imageを指定。サイズが大きくなりすぎないように、必要最低限のを指定するといい。Linux例:ubuntu:latestalpine:latest
RUN <command> コマンドを実行。よく使うコマンド:apt-get update && apt-get install -y
CMD ["executable", "param1", "param2", ...] コンテナを実行したときのデフォルトコマンド

その他書式

書式 説明
COPY ファイルやフォルダをコピーする場合
ADD tarの圧縮ファイルをコピーして解凍するする場合
ENTRYPOINT CMDと似ている。runで実行するときに、デフォルトコマンドを上書きされたなく場合に使う。
ENV 環境変数を設定する
WORKDIR Dockerfileに記述された内容を実行するディレクトリを変更する。anacondaをインストールする場合にroot直下ではなく、/opt/anaconda3にインストールしたり。

参考:公式ドキュメント

Dockerfile リファレンス(日本語)
Dockerfile reference(英語)

1
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
1
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?