Docker Cloud automated build fails because "local changes would be overwritten by checkout"

Summary: automated builds in my Docker repos started to fail complaining that “Your local changes […] would be overwritten by checkout” when the build process clones my repo in order to build it

Details: I have several repositories for which automated builds in Docker Cloud were working fine. I then started changing the configuration to build from different branches and I can’t figure out why I started getting the error stated in the Summary above. Why would the build environment have any local changes in the first place? Is it not executing git clone on an empty folder?

This is the resulting build log (information specific to my git repo edited out):

Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '###.###.###.###' to the list of known hosts.
error: Your local changes to the following files would be overwritten by checkout:
<path-to-a-Typescript-file>
Please, commit your changes or stash them before you can switch branches.
Aborting
please ensure the correct public key is added to the list of trusted keys for this repository and the remote branch exists. (1)
ERROR: Build failed: please ensure the correct public key is added to the list of trusted keys for this repository and the remote branch exists. (1)
ERROR: Build failed with exit code 2
ERROR: Build in '<branch-name>:<build-context-directory>:<path-to-Dockerfile>' (2320b4c0) failed in 0:01:01

I’m not even sure there’s anything I can try to do about it with hooks, since the first one available is post-checkout, and checkout is what seems to be failing…

Any ideas?

To make this worse, I got the exact same error after creating a brand new repo and configuring auto-builds there. How can that be? Is the build system using a single build agent for each account/organization? I can’t see why a brand new Docker repo would have “local changes” on code that it just cloned from a git repository.

I tried triggering the builds again right now to see if anything had changed and it seems that they are building correctly… but the same file that was referenced in the error before still shows as modified when the build process switches to the branch that it’s supposed to build. I’d still like to know why are there any local changes wherever it is that Docker clones the git repo?

Building in Docker Cloud's infrastructure...
Cloning into '.'...
Warning: Permanently added the RSA host key for IP address '###.###.###.###' to the list of known hosts.
Switched to a new branch '<my-branch>'
M	<path-to-Typescript-file-from-error>
KernelVersion: 4.4.0-93-generic
Arch: amd64
BuildTime: 2017-08-17T22:50:04.828747906+00:00
ApiVersion: 1.30
Version: 17.06.1-ce
MinAPIVersion: 1.12
GitCommit: 874a737
Os: linux
GoVersion: go1.8.3
Starting build of index.docker.io/<my-docker-repo>...
Step 1/19 : FROM microsoft/dotnet:2.0-runtime AS base

I just got the same error on a different repo whose previous build (around 2 months ago) had succeeded, and that we didn’t touch at all in the meantime. I’d still like to hear from someone at Docker regarding why are there any local changes to any files when the automated build tries to check-out my code to build an image.

I had the same error in my repository and I managed to fix it.

The problem is that Docker Hub was cloning the master branch before switching to the branch that I setup the automatic build, and there was some files with CRLF line ending there that got changed.

When Hub clone a CRLF text file, it’s doing a LF normalization and don’t commit it, so it gets in a dirty state and git refuses to switch the branch because that would override the dirty files.

To fix that I had to change the line ending of the offending files manually with my editor in the master branch. After that I could build the other branches in Docker Hub.

1 Like