Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: "lstat no such file or directory" error when building image. File is there

Tags:

docker

I want to deploy a simple JS Boilerplate to Docker Cloud. I use a Dockerfile that I already used for a different Boilerplate and image. The Dockerfile is pretty simple. It is just based on the official nginx, adds two config files and then the output folder of my gulp boilerplate to the nginx root. So I copied it from the one directory to the new boilerplate since I want to try this one.

The error I'm getting is this (last line)

Sending build context to Docker daemon 277.5 kB
Step 1 : FROM nginx
 ---> af4b3d7d5401
Step 2 : MAINTAINER Ole Bjarnstroem
 ---> Using cache
 ---> f57bc23d9444
Step 3 : ENV LANG en_US.UTF-8
 ---> Using cache
 ---> f6f4a76092dd
Step 4 : COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
 ---> Using cache
 ---> c4f83a39ba73
Step 5 : COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf
 ---> Using cache
 ---> 6fe5a6b61d9f
Step 6 : ADD ./dist /usr/share/nginx/html
lstat dist: no such file or directory

But the dist folder is there.

.
├── Dockerfile
├── JSCS.intellij.formatter.xml
├── README.md
├── app
├── dist
├── gulpfile.babel.js
├── jspm.conf.js
├── jspm_packages
├── karma.conf.js
├── nginx
├── node_modules
├── package.json
├── tsconfig.json
├── tslint.json
├── typings
└── typings.json

It might be noteworthy that the folder to be copied was called ./public So I could imagine that this is some kind of weird Docker Cache issue.

My Dockerfile:

FROM nginx

ENV LANG en_US.UTF-8

# Copy configuration files
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
COPY ./nginx/default.conf /etc/nginx/conf.d/default.conf

# Add Gulp output folder to server root
ADD ./dist /usr/share/nginx/html

# Port configuration
EXPOSE 8080

What I tried so far:

  • Deleting dangling and unused images
  • Deleting the image that was produced by the same docker file before
  • Using a different tag

My build command:

docker build -t my_repo/my_app .

Thanks for your help!

Edit: Every other folder works. It is also not a problem of file permissions. It seems, that Docker just doesn't like the dist folder. Which sucks.

like image 763
Ole Spaarmann Avatar asked Mar 23 '16 13:03

Ole Spaarmann


3 Answers

Well, stupid me. There was a .dockerignore file with dist in the project folder... Case closed

like image 85
Ole Spaarmann Avatar answered Nov 07 '22 10:11

Ole Spaarmann


I had the same issue, but it wasn't the .dockerignore, I forgot to specify the directory to run docker in. In my case that directory was . My full command before was

docker build - < Dockerfile

and after was

docker build . < Dockerfile
like image 31
Rich Avatar answered Nov 07 '22 11:11

Rich


I put the directory after the build command used -f to specify the dockerfile

eg:

sudo docker build . -t test:i386 -f mydockerfile

The dot after build is the directory to build from, in this case present dir.

like image 7
Vijay47 Avatar answered Nov 07 '22 10:11

Vijay47