How to install gulp on a docker with docker-compose

15,683

You need to run npm install gulp AFTER WORKDIR /app, so that gulp is installed locally in node_modules/gulp. But you already did that and having the same error. It's because in your docker-compose-dev.yml, you are mounting host directory as /app volume inside docker container. So local changes in /app directory is lost when you are running the container.

You can either remove volumes from docker-compose-dev.yml or run npm install gulp in host machine.

Share:
15,683
Mr Mixin
Author by

Mr Mixin

Updated on June 20, 2022

Comments

  • Mr Mixin
    Mr Mixin almost 2 years

    I am using docker compose and this is my yaml file

    web:
      dockerfile: Dockerfile-dev
      build: .
      command: gulp
      volumes:
        - .:/app
      ports:
        - '9001:9001'
    

    and here is my docker file

    FROM node:0.12.7
    
    RUN npm install -g bower gulp
    
    ADD . /app
    WORKDIR /app
    
    RUN bower install --allow-root
    

    Then i run

    docker-compose -f docker-compose-dev.yml build
    docker-compose -f docker-compose-dev.yml up
    

    But i get the following error

    Recreating web_web_1...
    Attaching to web_web_1
    web_1 | [07:39:08] Local gulp not found in /app
    web_1 | [07:39:08] Try running: npm install gulp
    web_web_1 exited with code 1
    Gracefully stopping... (press Ctrl+C again to force)**strong text**
    

    I have tried adding the line RUN npm install gulp before and after WORKDIR /app to get it installed locally but i get the same error

    Help

  • Mr Mixin
    Mr Mixin over 8 years
    This was spot on, thanks so much. i have literally spent 1.5 days working on this
  • Francisco Quintero
    Francisco Quintero over 6 years
    This is it. Removing the volumes section made the container run. Thanks.