Answer the question
In order to leave comments, you need to log in
How to configure networks and volumes in docker?
Good evening, I'm trying to run a nodejs application and a mongodb database in docker. An error occurs on startup:
$ docker-compose up --build -d
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.networks: 'app-network'
Unsupported config option for services.volumes: 'dbdata'
20.10.3
FROM node:14.16.0-alpine3.10
RUN mkdir -p /app/node_modules && chown -R node:node /app
WORKDIR /app
COPY package*.json .
USER node
RUN npm install
COPY --chown=node:node . .
CMD [ "npm", "start" ]
version: "3.8"
services:
node-app:
build:
context: .
dockerfile: Dockerfile
container_name: node-app
ports:
- "80:80"
env_file: .env
networks:
- app-network
mongodb:
image: mongo:4.1.8-xenial
container_name: mongodb
env_file: .env
environment:
- MONGO_INITDB_ROOT_USERNAME=$MONGO_USERNAME
- MONGO_INITDB_ROOT_PASSWORD=$MONGO_PASSWORD
volumes:
- dbdata:/data/db
networks:
- app-network
networks:
app-network:
volumes:
dbdata:
MONDO_PROTOCOL="mongodb"
MONGO_USERNAME="some_name"
MONGO_PASSWORD="some_password"
MONGO_HOSTNAME="127.0.0.1"
MONGO_PORT="27017"
MONGO_DB="test"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question