Docker error: Parcel (Parceljs) won't work in Docker

Viewed 911

When I run my nodejs application in a docker container, the parcel build step fails with an error message that isn't helpful. The app runs fine locally without Docker.

I created a simple app to test my problem out. My package.json is

{
  "name": "test",
  "version": "1.0.0",
  "scripts": {
    "start": "parcel index.html"
  },
  "dependencies": {
    "parcel": "^2.0.0-beta.2"
  }
}

and my Dockerfile is

FROM alpine:latest

RUN apk update &&\
    apk upgrade &&\
    apk add nodejs npm

# Install app dependencies
COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 80
EXPOSE 1234

CMD [ "npm", "start" ]

The error message I get is [Error: Invalid argument]

More detailed steps:

  1. The commands I run to build docker is docker build .
  2. Then I run the app with docker run test_app

The build step works fine and creates the image. When I run the container, this is the entire output

docker run test_app

> test@1.0.0 start
> parcel index.html

[Error: Invalid argument]

I have tried the following:

  1. Using node:13, node:14, node:16 and my latest attempt was with alpine as the Docker image
  2. I tried overriding as many of parcel js default options as I could to see if I could override the problem.

Again the issue only happens inside a docker container so I'm not sure if I'm doing anything wrong with my Docker setup. Thanks in advance!

1 Answers

Are you running parcel from / ? Try making a WORKDIR and then run parcel, works for me.

Related