Docker image working with docker run but not with docker-compose up Docker image working with docker run but not with docker-compose up docker docker

Docker image working with docker run but not with docker-compose up


The image will work fine when the code is in the context of build, because all commands RUN will be executed during docker build image process.

When you instance a image as you do on docker-compose, you are not running:

RUN npm install --force

because it was executed during build image time. No during launch container.

So, for solve your problem and considering how your image was built you need not to include a volume instead include your code as build context.

version: "3.7"services:  webapp:    build:      context: ./dir      dockerfile: Dockerfile

https://docs.docker.com/compose/compose-file/