10
12

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

Dockerfile ビルド時間短縮 tips

Posted at

ubuntu や centos などの dockerhub イメージを使って Dockerfile を書くとき、大抵の場合 apt-get update や yum update を先頭に書きます。

FROM ubuntu:latest
RUN apt-get update && apt-get -y upgrade && apt-get clean

毎回たくさんのダウンロードが実行される時間を省略するために以下をやっておきます。

ホストOS 上で docker run

docker run -it --name t1 ubuntu:latest 

コンテナ上で apt-get update など実行して exit

apt-get update && apt-get -y upgrade && apt-get clean
exit

同じ名前でイメージ作成

docker commit t1 ubuntu:latest ← 同じ名前でイメージ更新
docker rm t1 ← 仮コンテナを削除

これで Dockerfile の FROM はいじらずにビルド時間を短縮できます。

10
12
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
10
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?