POST POST

NOV
23
2023

Docker COPY not Finding Files

ORIGINALLY POSTED TO: https://blog.simontimms.com/2023/11/23/cannot-copy

My dad once told me that there are no such things a problems just solutions waiting to be applied. I don't know what book he'd just read or course he'd just been on to spout such nonsense but I've never forgotten it.

Today my not problem was running a docker build wasn't copying the files I was expecting it to. In particular I had a themes directory which was not ending up in the image and in fact the build was failing with something like

1
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref b1f3faa4-fdeb-41ed-b016-fac3862d370a::pjh3jwhj2huqmcgigjh9udlh2: "/themes": not found

I was really confused because themes absolutly did exist on disk. It was as if it wasn't being added to the build context. In fact it wasn't being added and, as it turns out, this was because my .dockerignore file contained

1
**

Which ignores everything from the local directory. That seemed a bit extreme so I changed it to

1
2
** 
!themes

With this in place the build worked as expected.


Simon Timms

Email Email
Web Web
Twitter Twitter
GitHub GitHub
RSS

Looking for someone else?

You can find the rest of the Western Devs Crew here.

© 2015 Western Devs. All Rights Reserved. Design by Karen Chudobiak, Graphic Designer