Reputation:
I have a docker-compose file that consists of a custom image for my app, and the official mongo image. It works fine, as long as I don't try to map the volume for my app, which I'm trying to do for creating a development docker-compose file. I have a feeling I may have the volume set wrong in my docker-compose.dev.yml file. I've tried setting the volume different ways but always get an error. I'm not sure how I'd map the volume so that any changes I made to the code would be changed in the container
Below is my docker-compose.dev.yml file, my Dockerfile for my app, and my package.json file. I'll also include the error I'm seeing
Thank you for any help you can give
docker-compose.dev.yml
version: "3"
services:
app:
container_name: database
restart: always
build: .
volumes:
- ./:/usr/src/app
ports:
- "8080:8080"
links:
- mongo
mongo:
container_name: mongo
image: mongo:4
ports:
- "27017:27017"
Dockerfile
FROM node:10
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package*.json ./
RUN npm install
# Bundle app source into container
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]
package.json
{
"name": "database",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.16.0",
"http-errors": "~1.6.2",
"morgan": "~1.9.0",
"pug": "2.0.0-beta11"
}
}
Error Im getting...
WARNING: Image for service app was built because it did not already exist.
To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating mongo ... done
Creating database ... done
Attaching to mongo, database
database | npm ERR! path /usr/src/app/package.json
database | npm ERR! code ENOENT
database | npm ERR! errno -2
database | npm ERR! syscall open
database | npm ERR! enoent ENOENT: no such file or directory, open
'/usr/src/app/package.json'
database | npm ERR! enoent This is related to npm not being able to find a file.
database | npm ERR! enoent
database |
database | npm ERR! A complete log of this run can be found in:
database | npm ERR! /root/.npm/_logs/2019-01-11T17_20_49_720Z-debug.log
Upvotes: 1
Views: 1943
Reputation:
I had the volume wrong in my docker-compose.dev.yml
I had it as
- ./:/usr/src/app
It needed to be
- .:/usr/src/app
Upvotes: 4