1

I am trying to creating a container with Node + Electron, but the container it's not starting when I run the command

docker logs idcontainer

its showing this error:

webpack serve --mode development --progress --config  build/webpack.dev.conf.js electron
sh: 1: webpack: not found

this is my dockerfile

FROM node:19-bullseye

RUN apt-get update
RUN apt-get update && apt-get install \
    git libx11-xcb1 libxcb-dri3-0 libxtst6 libnss3 libatk-bridge2.0-0 libgtk-3-0 libxss1 libasound2 \
    -yq --no-install-suggests --no-install-recommends \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN mkdir -p /home/app/ && chown -R node:node /home/app/

WORKDIR /home/app/
USER node

COPY . /home/app/

RUN npm install --save-dev webpack webpack-cli webpack-dev-server
RUN npm install --save-dev electron
RUN npm install install
RUN npx electron-rebuild

USER root

RUN chown root /home/app/node_modules/electron/dist/chrome-sandbox
RUN chmod 4755 /home/app/node_modules/electron/dist/chrome-sandbox

USER node
EXPOSE 6665

CMD ["npm", "run"] 

CMD ["npm", "start", "electron"] 

and this is my docker-compose

version: "3"
services:
    service:
        build: .
        ports:
            - '6665:6665'
        container_name: serviceDesktop
        volumes:
            - .:/home/app

to create a new container with Node + Electron

midnight-coding
  • 2,857
  • 2
  • 17
  • 27
RZYeah
  • 56
  • 4
  • Running GUI applications in Docker is finicky and non-portable (also see [Can you run GUI applications in a Linux Docker container?](https://stackoverflow.com/questions/16296753/can-you-run-gui-applications-in-a-linux-docker-container) for some of the machinations required). Especially if you're going to use a bind mount so that the code comes from your host system and not an image, you'll probably find this easier to run from the host. – David Maze Mar 17 '23 at 20:12
  • The specific error is probably coming from the `volumes:` mount hiding everything the image does, including its `node_modules` tree, and you might try deleting that block from the Compose file. – David Maze Mar 17 '23 at 20:12

0 Answers0