【发布时间】:2019-01-09 05:39:15
【问题描述】:
当我为 busybox 容器尝试 df -h 时,我得到以下结果:
$ docker run -it busybox du -h
# expected results
我需要的是df -b 的输出,它给了我以下信息:
$ docker run -it busybox du -b
du: invalid option -- b
BusyBox v1.30.0 (2018-12-31 18:16:17 UTC) multi-call binary.
Usage: du [-aHLdclsxhmk] [FILE]...
Summarize disk space used for each FILE and/or directory
-a Show file sizes too
-L Follow all symlinks
-H Follow symlinks on command line
-d N Limit output to directories (and files with -a) of depth < N
-c Show grand total
-l Count sizes many times if hard linked
-s Display only a total for each argument
-x Skip directories on different filesystems
-h Sizes in human readable format (e.g., 1K 243M 2G)
-m Sizes in megabytes
-k Sizes in kilobytes (default)
由于许多标准实用程序在busybox 图像中被修剪或不存在,因此这种行为并不奇怪。作为dockerhub的busybox页面suggests:
FROM busybox COPY ./my-static-binary /my-static-binary CMD ["/my-static-binary"]
所以,我创建了一个包含以下内容的 Dockerfile,试图将我的 Ubuntu 16.04 du 二进制文件复制到映像中:
FROM busybox
COPY /usr/bin/du /bin/du
CMD ["/bin/du", "-b"]
但是当我尝试docker build 时,我收到以下错误:
$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM busybox
---> 3a093384ac30
Step 2/3 : COPY /usr/bin/du /bin/du
COPY failed: stat /var/lib/docker/tmp/docker-builder362173879/usr/bin/du: no such file or directory
我不知道将实用程序添加到此类最小图像是否是正确的方法,但如果您让我知道实用程序(例如(完整)du、curl 等)可以使用的方式,我将不胜感激鉴于没有像 apt 这样的包管理器,所以添加。
【问题讨论】:
标签: docker dockerfile busybox