Reputation: 357
I'm running docker build and it's taking an awfully long time to run. Infact, it doesn't complete and I have to CTRL + C to quit.
Last night things were working fine. When I returned to the computer and tried to rebuild it started acting strange.
Here's my command:
docker build -t mywebsite/backend .
When I ran it I noticed this:
Sending build context to Docker daemon 213.8 MB
Step 1 : FROM ubuntu:14.04
I have no idea why the file size was 213.8. The only directory that is large is node_modules
and that contains .dockerignore
so it shouldn't be touching that directory.
After that ran I had an error, so I fixed it and reran:
docker build -t mywebsite/backend .
This time it just hung. And continues to do so.
Here is my Dockerfile
FROM ubuntu:14.04
# Set env. variables
ENV DEBIAN_FRONTEND noninteractive
# Application
ENV APP_PORT 3000
# Amazon
ENV AMAZON_BUCKET mybucket
ENV AMAZON_ACCESS_KEY_ID mykey
ENV AMAZON_SECRET_ACCESS_KEY mytoken
# Set working directory
WORKDIR ~/vms
# Install NodeJS
RUN apt-get update; apt-get install -y curl;
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN apt-get install -y nodejs
# Install node dependencies
ADD package.json package.json
RUN npm install --production
# Copy files to the container
ADD src src
EXPOSE 3000
# Start application
RUN npm start
The directory I am in when I run the command is the one that contains the Dockerfile:
- backend
- node_modules
- src
- config
- routes
- views
index.js
Dockerfile
package.json
I'm running docker on Ubuntu 14.04
Upvotes: 22
Views: 32413
Reputation: 5363
What @sulogonamission says is perfect.
.dockerignore
in the directory where the Dockerfile exists/node_modules
(or the exact path of node_modules directory)Upvotes: -7
Reputation: 9642
I have no idea why the file size was 213.8. The only directory that is large is node_modules and that contains .dockerignore so it shouldn't be touching that directory.
That's not how .dockerignore
works. The .dockerignore
file should be in the same directory as your Dockerfile
and lists patterns to ignore. Create a file in backend
called .dockerignore
which simply contains the line node_modules
.
See here for more information: https://docs.docker.com/engine/reference/builder/#dockerignore-file
Upvotes: 21