gpt4 book ai didi

download - Docker删除下载的文件

转载 作者:行者123 更新时间:2023-12-02 18:57:33 24 4
gpt4 key购买 nike

我正在尝试设置一个Docker容器来测试Magento扩展。我希望使用这样的Dockerfile做到这一点:

FROM php:5.4-apache
WORKDIR /var/www/html
ADD http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz /var/www/html
# Other installation steps

但这失败了:
2014/09/27 17:03:25 lchown /mnt/sda1/var/lib/docker/aufs/mnt/d5ced8f20d760458093f2993ea25ffa9a644c93d5b134e793f820f53dfc2d70d/var/www/html/tmp: not a directory

我收集到它与在OS X上使用boot2docker有关系。(我回想起OS X在与Docker共享文件系统时遇到了一些问题。)因此,我再次尝试使用此Dockerfile:
FROM php:5.4-apache
WORKDIR /var/www/html
# We should be able to use ADD to fetch a remote file, but
# something is causing that to fail (OS X Docker limitations, I guess?)
RUN ["/usr/bin/curl", "-O", "http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz"]
RUN ["/bin/tar", "-xzf", "magento-1.9.0.1.tar.gz"]
# Other installation steps

当我运行上面的命令时,curl执行得很好并且没有错误退出,但是结果容器不包含下载的文件,因此下游tar命令失败。
Step 2 : RUN ["/usr/bin/curl", "-O", "http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz"]
---> Running in 2695c5e95f77
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.9M 100 21.9M 0 0 817k 0 0:00:27 0:00:27 --:--:-- 842k
---> bb716a60c4ef
Removing intermediate container 2695c5e95f77
Step 3 : RUN ["/bin/tar", "-xzf", "magento-1.9.0.1.tar.gz"]
---> Running in 95cc533947c1
tar (child): magento-1.9.0.1.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
/bin/tar: Child returned status 2
/bin/tar: Error is not recoverable: exiting now
2014/09/27 17:07:47 The command [/bin/tar -xzf magento-1.9.0.1.tar.gz] returned a non-zero code: 2

如果我检查中间容器,则文件确实不存在。
$ docker run bb716a60c4ef /bin/sh -c 'pwd && ls -al'
/var/www/html
total 8
drwxr-xr-x 2 www-data www-data 4096 Sep 27 21:09 .
drwxr-xr-x 4 root root 4096 Sep 23 11:09 ..

那么它去了哪里,如何设置允许我下载和修改文件系统的Dockerfile?

最佳答案

这里有几件事要注意。我将从第一个Dockerfile开始,因为该修复很容易:

FROM php:5.4-apache
WORKDIR /var/www/html
ADD http://www.magentocommerce.com/downloads/assets/1.9.0.1/magento-1.9.0.1.tar.gz /var/www/html/
# Other installation steps

你懂了吗?在目的地的末尾添加 /会告诉 ADD命令将其视为文件夹。有关复制规则,请参见第3点,即 https://docs.docker.com/reference/builder/#add

第二个 Dockerfile对我来说还是个谜。但是我怀疑这与将父图像设置 /var/www/html设置为跳过层版本控制的卷有关。参见 https://github.com/docker-library/php/blob/master/5.4/apache/Dockerfile#L46

关于download - Docker删除下载的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26079271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com