When I was making a docker environment construction and entered a command to initialize npm, an Error occurred.
#docker-compose run --rm node npm init
ERROR: The Compose file './../docker-compose.yml' is invalid because:
Unsupported config option for services.app: 'node'
Looking at the contents of this Error, it seems that an Error has occurred around'node'in the docker-compose.yml file. .. ..
When I checked the relevant part of the yml file, "services-> node" was originally correct, but the indent was shifted to "services-> app-> node". .. ..
Mistake ↓
version: '3'
services:
app:
image: nginx:latest
container_name: "app"
ports:
- "8080:80"
volumes:
- ./src/html:/app
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
node:
image: node:10
container_name: node
tty: true
working_dir: /usr/src/app
volumes:
- ./src:/usr/src/app
Correct ↓
version: '3'
services:
app:
image: nginx:latest
container_name: "app"
ports:
- "8080:80"
volumes:
- ./src/html:/app
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
node:
image: node:10
container_name: node
tty: true
working_dir: /usr/src/app
volumes:
- ./src:/usr/src/app
After running the modified code
#docker-compose run --rm node npm init
Creating network "app_default" with the default driver
Pulling node (node:10)...
10: Pulling from library/node
0400ac8f7460: Pull complete
fa8559aa5ebb: Pull complete
da32bfbbc3ba: Pull complete
e1dc6725529d: Pull complete
572866ab72a6: Pull complete
63ee7d0b743d: Pull complete
90a199058c87: Pull complete
eec01b4217d9: Pull complete
a6a01f1bcd7b: Pull complete
Digest: sha256:9d06418fa4335f9cf96c59d5c09372f7a56329e7234456ee9fe2340c4ac35a95
Status: Downloaded newer image for node:10
Creating app_node_run ... done
Successful! !! !!