Skip to content

Instantly share code, notes, and snippets.

@twiddler
Created December 7, 2022 20:41
Show Gist options
  • Save twiddler/7deb70deec62b298738858cee5aa00bb to your computer and use it in GitHub Desktop.
Save twiddler/7deb70deec62b298738858cee5aa00bb to your computer and use it in GitHub Desktop.
Dockerized node app cannot access its own node_modules if node_modules is missing on host
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm i
rmdir node_modules
sudo docker build . --tag bug
sudo docker run -v $(pwd):/app:ro -v /app/node_modules bug
rmdir node_modules
sudo docker build . --tag bug
mkdir node_modules
sudo docker run -v $(pwd):/app:ro -v /app/node_modules bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment