Where’s that log file? Debugging failed Docker builds

栏目: IT技术 · 发布时间: 4年前

内容简介:You’ve got a nice newSo—now what? That log file isn’t on your host computer’s filesystem, it’s in the temporary image that build was creating.How do you read that log file? By understanding just a little bit more about how Docker builds image.

You’ve got a nice new Dockerfile , and it’s time to try it out:

$ docker build -t mynewimage .
Sending build context to Docker daemon  3.072kB
Step 1/3 : FROM python:3.8-slim-buster
 ---> 3d8f801fc3db
Step 2/3 : COPY build.sh .
 ---> 541b65a7b417
Step 3/3 : RUN ./build.sh
 ---> Running in 9917e3865f96
Building...
Building some more...
Build failed, see /tmp/builderr024321.log for details
The command '/bin/sh -c ./build.sh' returned a non-zero code: 1

So—now what? That log file isn’t on your host computer’s filesystem, it’s in the temporary image that build was creating.

How do you read that log file? By understanding just a little bit more about how Docker builds image.

How Docker builds images

To a first approximation, Docker builds images inside containers. In particular, each RUN command is a new container started from the image created by the previous step, running whatever the command is.

That means that build.sh step was run in a container.

We can list containers:

$ docker container ls
$

Nothing there—because it’s not a running container. So let’s look at dead containers:

$ docker container ls -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS
9917e3865f96   541b65a7b417   "/bin/sh -c ./build.…"   3 minutes ago   Exited (1) 3 minutes ago

And there it is!

If you have multiple dead containers, you can recognize yours either by the command line, or by the image ID. Notice that the image ID, 541b65a7b417, is the same as the image ID created in step 2 in the docker build we ran earlier.

It’s in the container!

We’ve made some progress: we know that the log file is probably inside that container. And now we can copy the file out of the container.

The container ID is 9917e3865f96 , but we can just use the first few characters to refer to it:

$ docker container cp 9917:/tmp/builderr024321.log .
$ cat builderr024321.log
Error, missing flux capacitor!

And there you have it: the build failed because of a missing flux capacitor.


以上所述就是小编给大家介绍的《Where’s that log file? Debugging failed Docker builds》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

可伸缩架构

可伸缩架构

【美】Lee Atchison / 张若飞、张现双 / 电子工业出版社 / 2017-7 / 65

随着互联网的发展越来越成熟,流量和数据量飞速增长,许多公司的关键应用程序都面临着伸缩性的问题,系统变得越来越复杂和脆弱,从而导致风险上升、可用性降低。《可伸缩架构:面向增长应用的高可用》是一本实践指南,让IT、DevOps和系统稳定性管理员能够了解到,如何避免应用程序在发展过程中变得缓慢、数据不一致或者彻底不可用等问题。规模增长并不只意味着处理更多的用户,还包括管理更多的风险和保证系统的可用性。作......一起来看看 《可伸缩架构》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具