Node.js docker image with PNPM enabled via corepack
89
Node.js docker image with PNPM enabled via corepack
Dockerfile in your Node.js app project# specify the node base image with your desired version node:<version>
FROM <image-name:tag>
# replace this with your application's default port
EXPOSE 8888
You can then build and run the Docker image:
$ docker build -t my-nodejs-app .
$ docker run -it --rm --name my-running-app my-nodejs-app
If you prefer Docker Compose:
version: "3.4"
services:
node:
image: "<image-name:tag>"
working_dir: /home/node/app
volumes:
- ./:/home/node/app
expose:
- "8081"
ports: # use if it is necessary to expose the container to the host machine
- "8001:8001"
command: "pnpm start"
You can then run using Docker Compose:
$ docker-compose up -d
Docker Compose example mounts your current directory (including node_modules) to the container.
It assumes that your application has a file named package.json
defining start script.
For many simple, single file projects, you may find it inconvenient to write a
complete Dockerfile. In such cases, you can run a Node.js script by using the
Node.js Docker image directly:
$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app -w /usr/src/app <image-name:tag> node your-daemon-or-script.js
Content type
Image
Digest
sha256:33bd19577…
Size
48.7 MB
Last updated
over 2 years ago
docker pull chronoscloud/node-pnpm:v20-9.1.0