環境情報
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.15.6
BuildVersion: 19G73
$ docker --version
Docker version 20.10.0, build 7287ab3
Docker Desktop version 3.0.3
事象
Dockerfileの内容
FROM docker/whalesay:latest
RUN echo `date +"%Y-%m-%d %H:%M:%S"`
CMD date | cowsay
出力結果
$ docker build -t docker-whale . --no-cache
[+] Building 0.4s (6/6) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 234B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/docker/whalesay:latest 0.0s
=> CACHED [1/2] FROM docker.io/docker/whalesay:latest 0.0s
=> [2/2] RUN echo `date +"%Y-%m-%d %H:%M:%S"` 0.3s
# ここにechoの結果が表示されてほしいのだが、表示されない。
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:e927115c90cf9ec5c69d8bf8664afe1e6483514e86b7f94f76da5050a0f0f65e 0.0s
=> => naming to docker.io/library/docker-whale
解決策
docker build
の時に --progress plain
を指定する。
$ docker build -t docker-whale . --progress plain --no-cache
#1 [internal] load build definition from Dockerfile
#1 sha256:5b446167b8f2660da37e9b45a41f805c9fc491d4bc0e0d278051f6613c08384c
#1 transferring dockerfile: 234B done
#1 DONE 0.0s
#2 [internal] load .dockerignore
#2 sha256:a94a1fefc4aa855d02da542c8c83ce7747028a0f7dce44469f27ba31896d7b89
#2 transferring context: 2B done
#2 DONE 0.0s
#3 [internal] load metadata for docker.io/docker/whalesay:latest
#3 sha256:d59230d59547a76b6e0d9b846a193c02fc104868f78213593f8e7d8ae95dcf2c
#3 DONE 0.0s
#4 [1/2] FROM docker.io/docker/whalesay:latest
#4 sha256:6fe26e5b9899a35aa22f0c64d5f0e8eedced7ba4b2f0880373a944a3c2831547
#4 CACHED
#5 [2/2] RUN echo `date +"%Y-%m-%d %H:%M:%S"`
#5 sha256:188e3f318e8343d0d960ed39317fad4327f9530bd6446d2a8fb280ee1324f963
#5 0.211 2021-01-06 15:40:08 # echoの内容が表示される!
#5 DONE 0.3s
#6 exporting to image
#6 sha256:e8c613e07b0b7ff33893b694f7759a10d42e180f2b4dc349fb57dc6b71dcab00
#6 exporting layers done
#6 writing image sha256:d2a4932df513014ef9f1cac98183aa781e776f6437ac442573d4b9a1bf8c960e done
#6 naming to docker.io/library/docker-whale done
#6 DONE 0.0s