Github 构建Dockerfile时,我可以';t在同一个定义中没有Perl和curl/git

Github 构建Dockerfile时,我可以';t在同一个定义中没有Perl和curl/git,github,docker,alpine,Github,Docker,Alpine,我正试图使用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

我正试图使用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"]
欢迎有任何见解

有几件事需要尝试

  • 为每次安装尝试其他“运行”命令
  • 在每个步骤之后删除缓存
  • 在构建docker映像时,请使用“无缓存”选项<代码>docker构建-无缓存

我运行了您的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
如果您的输出与上述不同,请更新您的问题,并提供更多详细信息


编辑:根据您的请求,我还包括了一个导出,二进制文件显示无问题:

$ 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

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

我希望在tar文件中看到这些。我生成的tar文件只包含bin、dev和etc顶级文件夹……我在其中找不到perl、curl或git可执行文件。下面是一组用于导出以在GitHub中使用的命令。
docker build-f docker.perl-t docker.perl。docker create——名称docker.perl docker.perl/bin/true docker export docker.perl | gzip>docker.perl.tar.gzhhello。谢谢你检查这个。我无法在Windows10Pro上使用Docker for Windows,也无法在Windows10Home上使用Docker工具箱。我可以尝试在Linux计算机上构建导出,看看这是否是导致我悲伤的原因。您好:问题是,在Windows中使用WinRar验证生成的导出时,符号链接没有正确解析,导致文件似乎丢失。当只添加perl时,没有符号链接,因此在验证文件时没有问题。感谢您指出它确实是在Linux下正确构建的。在那之后,我意识到符号链接让我担心。IskiE@IskieIsketerol谢谢你的跟进,很高兴听到Docker没有崩溃,至少是这样。在Linux上本机运行Docker确实为我消除了许多其他人遇到的问题。谢谢。我确实试过每一种。如上所述,我导出的tar文件不包含可执行文件。