-1

我正在尝试使用 Dockerfile 构建一个包含 Perl、curl 和 git 的小型导出,以便与 GitHub 一起用作 chroot 环境。任何将 curl 或 git 放入 Dockerfile 的尝试最终都会从导出的 tar 文件中删除目录。我可以将 Perl 与 Firefox 等其他软件包结合起来,最终得到一个可用的 tar。

这是 Dockerfile。如前所述,如果我只要求 Perl 或使用 Perl 的 curl / git 以外的任何东西,它确实有效。

FROM gliderlabs/alpine:3.4

RUN apk add --update \
    curl \
    perl-dev \
    git \
  && rm -rf /var/cache/apk/*

ENTRYPOINT ["/usr/bin/perl", "-de0"]

欢迎任何见解。

4

2 回答 2

0

我运行你的 Dockerfile 没有问题:

$ cat df.alpine
FROM gliderlabs/alpine:3.4

RUN apk add --update \
    curl \
    perl-dev \
    git \
  && rm -rf /var/cache/apk/*

$ docker build -t alpinetest -f df.alpine .
Sending build context to Docker daemon 37.89 kB
Step 1 : FROM gliderlabs/alpine:3.4
3.4: Pulling from gliderlabs/alpine
a03be5b52c0f: Pull complete
Digest: sha256:f34605566fc0827029c786094d104703f68953a7845d5bf4334c4c50fea6200c
Status: Downloaded newer image for gliderlabs/alpine:3.4
 ---> eeae34df12d9
Step 2 : RUN apk add --update     curl     perl-dev     git   && rm -rf /var/cache/apk/*
 ---> Running in 21aeec842908
fetch http://alpine.gliderlabs.com/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://alpine.gliderlabs.com/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
(1/9) Installing ca-certificates (20160104-r4)
(2/9) Installing libssh2 (1.7.0-r0)
(3/9) Installing libcurl (7.49.1-r0)
(4/9) Installing curl (7.49.1-r0)
(5/9) Installing expat (2.1.1-r1)
(6/9) Installing pcre (8.38-r1)
(7/9) Installing git (2.8.3-r0)
(8/9) Installing perl (5.22.2-r0)
(9/9) Installing perl-dev (5.22.2-r0)
Executing busybox-1.24.2-r9.trigger
Executing ca-certificates-20160104-r4.trigger
OK: 69 MiB in 20 packages
 ---> 7ee2fd822c7a
Removing intermediate container 21aeec842908
Successfully built 7ee2fd822c7a

$ docker run --rm -it alpinetest /bin/sh
/ # which git
/usr/bin/git
/ # which perl
/usr/bin/perl
/ # which curl
/usr/bin/curl

/ # perl -v

This is perl 5, version 22, subversion 2 (v5.22.2) built for x86_64-linux-thread-multi

Copyright 1987-2015, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

/ # curl --version
curl 7.49.1 (x86_64-alpine-linux-musl) libcurl/7.49.1 OpenSSL/1.0.2h zlib/1.2.8 libssh2/1.7.0
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

/ # git --version
git version 2.8.3

如果您的输出与上述不同,请使用更多详细信息更新您的问题。


编辑:根据您的要求,我还包括了一个导出,并且二进制文件显示没有问题:

$ docker create --name alpinetestc alpinetest /bin/true
$ docker export alpinetestc | gzip >alpinetest.tgz
$ tar -tvzf alpinetest.tgz usr/bin/git
-rwxr-xr-x 0/0         1944216 2016-05-26 10:44 usr/bin/git
$ tar -tvzf alpinetest.tgz usr/bin/curl
-rwxr-xr-x 0/0          173912 2016-05-30 12:11 usr/bin/curl
$ tar -tvzf alpinetest.tgz usr/bin/perl
-rwxr-xr-x 0/0            9872 2016-05-16 06:22 usr/bin/perl

您似乎没有提供足够的详细信息来重现您的问题。

于 2016-07-20T01:48:34.520 回答
0

有几件事要尝试

  • 为每次安装尝试额外的“运行”命令
  • 每一步后删除缓存
  • 在构建 docker 映像时不使用缓存选项。docker build -no-cache
于 2016-07-20T01:38:23.863 回答