Can't copy a file to a Docker image

Can't copy a file to a Docker image

Docker is so big in the tech world lately and Node apps too. I've been working with both a lot more. The current project entailed putting a Node app into a Docker Image. In fact it was Ghost Blog. With Docker to really optimise the Image, one needs to make the Image as lean as possible.

I tend to start a .dockerignore file with a * and add in exclusions going forward for whaterver I need. This keeps everything out of the Docker Image and ensures you only add what you explicitly want in the Image.

This has the major benifit of keeping the images as small as possible.

However if you forget to add something into the .dockerignore you'll get an error like so when you try to build the docker image:
dockerignore error

Looking at the .dockerignore file we can see the problem:

Eveything in the current directory and below is excluded except what is explicitly added in the .dockerignore file to not ignore.

The .dockerignore file should look like this:

Problem solved.

docker image built