I'm trying to build a Docker image whose dockerfile is in the parent directory. The dockerfile contains an ADD command:
# Copy files that need to live in the container into /app in the container
ADD ./app/container /app
I'm using this code to build the image
docker.buildImage({
context: path.join(__dirname, '..'),
src: ['Dockerfile'],
}, {
t: 'tag-name'
}).then(out => out.pipe(process.stdout));
When it reaches the ADD command, it fails with the following error:
ADD failed: stat /var/lib/docker/tmp/docker-builder409481196/app/container: no such file or directory
Why is docker looking in this directory even after I've clearly specified the context?
I'm just trying to replicate the effect of docker build -t tag-name ..
Your context appears correct, however the docker daemon is building in a tmp directory and your files aren't copied along with it. I ran into a similar issue today and ended up using the tarball solution.
const tarfs = require('tar-fs');
const pack = tarfs.pack(path.join(__dirname, '..'));
docker.buildImage(pack, {
t: 'tag-name'
}).then(out => out.pipe(process.stdout));
This is happening with me as well, I dont want to use tarball, any other fix for it?
+1 This is happening with me as well, I dont want to use tarball, any other fix for it?
Most helpful comment
Your context appears correct, however the docker daemon is building in a tmp directory and your files aren't copied along with it. I ran into a similar issue today and ended up using the tarball solution.