Docker Hub 自动构建失败。本地构建没问题

Docker Hub automated build failure. Local build is fine

我创建了一个 dockerfile to take an official php/apache image, add a bunch of dependencies and clone a GitHub repo, which works great when building a container image locally, but fails when I push it to GitHub and trigger an automated build at Docker Hub

失败的命令是git克隆

RUN git clone git://github.com/symphonycms/symphony-2.git /var/www/html 

失败的原因(根据Git)是

Step 5 : RUN git clone git://github.com/symphonycms/symphony-2.git /var/www/html && git checkout --track origin/bundle && git submodule update --init --recursive && git clone git://github.com/symphonycms/workspace.git && chown -R www-data:www-data *

[91mfatal: destination path '/var/www/html' already exists and is not an empty directory.

有人可以解释为什么在本地构建没有问题但在集线器上失败吗?

因此您推送的图像中包含 /var/www/html/ 目录(并且可能包含 git 存储库)。

在您的 docker 文件中尝试此操作以确保该目录不存在:

RUN rm -rf /var/www/html
RUN git clone git://github.com/symphonycms/symphony-2.git /var/www/html && git checkout --track origin/bundle && git submodule update --init --recursive && git clone git://github.com/symphonycms/workspace.git && chown -R www-data:www-data