2
votes

I've created a 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.

The command which fails is the git clone

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

and the reason for failure (according to Git) is

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.

Can someone explain why there is no problem building locally but a failure at the hub?

1

1 Answers

1
votes

So the image that you are pushing has the /var/www/html/ directory in it (and probably has the git repo in it).

Try this in your docker file to make sure the directory doesn't exist:

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