skip to Main Content

i have an issue while trying to create my first docker image.

here is my docker file:

FROM debian:9

RUN apt-get update -yq 
    && apt-get install -yq curl gnupg 
    && curl -sL https://deb.nodesource.com/setup_10.x | bash 
    && apt-get install -yq nodejs 
    && apt-get clean

ADD . /app/
WORKDIR /app
RUN npm install

EXPOSE 2368
VOLUME /app/logs

CMD npm run start

i do have a package.json file with all dependancies in my folder but i still have this error as a response:

ERROR: failed to solve: process "/bin/sh -c apt-get update      && apt-get install curl gnupg     && curl -sL https://deb.nodesource.com/setup_10.x | bash     && apt-get install -y nodejs     && apt-get clean" did not complete successfully: exit code: 100

2

Answers


  1. You can use node official docker image available from Docker Hub

    More on NodeJS Dockerizing

    FROM node:18 #node version
    
    # Create app directory
    WORKDIR /app
    
    # Layer caching
    COPY package*.json ./
    
    # Install app dependencies
    RUN npm install
    
    COPY . .
    
    EXPOSE 8080
    
    VOLUME /app/logs
    
    CMD npm run start
    
    Login or Signup to reply.
  2. To fix the issue, you can make the following modifications to your Dockerfile:

    # Use an official Node.js runtime as the base image
    FROM node:10
    
    # Create a directory
    WORKDIR /app
    
    # Copy the package.json and package-lock.json files into the container
    COPY package*.json ./
    
    # Install your application's dependencies
    RUN npm install
    
    # Copy the rest of your application code into the container
    COPY . .
    
    # Expose the port
    EXPOSE 2368
    
    # Define the command to run your application
    CMD npm start
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search