5

I am attempting to use gulp inside a Docker container.

I have the following Dockerfile

FROM golang:alpine
RUN apk --update add --no-cache git nodejs
RUN npm install --global gulp
ENV GOPATH=/go PATH=$PATH:/go/bin
VOLUME ["/go/src/github.com/me/sandbox", "/go/pkg","/go/bin"]
WORKDIR /go/src/github.com/me/sandbox
CMD ["gulp"]

and I have the following docker-compose.yml

version: '2'
services:
service:
    build: ./service
    volumes:
        - ./service/src/:/go/src/github.com/me/sandbox

docker-compose build builds successfully, but when I run docker-compose up, I get the following error message

Recreating sandbox_service_1
Attaching to sandbox_service_1
service_1  | [22:03:40] Local gulp not found in /go/src/github.com/me/sandbox
service_1  | [22:03:40] Try running: npm install gulp

I have tried several different things to try to fix it.

  • Tried also installing gulp-cli globally and locally
  • Tried installing gulp locally with npm install gulp
  • Tried moving the npm install --global gulp after the WORKDIR
  • Tried different paths for volumes.

My guess is that it has something to do with the volumes, because when I get rid of anything having to do with a volume, it doesn't complain.

Mr project structure is shown in screenshot below:

enter image description here

TheJediCowboy
  • 8,924
  • 28
  • 136
  • 208
  • Possible duplicate of [Why do we need to install gulp globally and locally?](http://stackoverflow.com/questions/22115400/why-do-we-need-to-install-gulp-globally-and-locally) – Sven Schoenung Dec 08 '16 at 08:18

2 Answers2

5

This is what worked for me.

RUN npm install -g gulp
RUN npm link gulp
Lukasz Dynowski
  • 11,169
  • 9
  • 81
  • 124
3

You need a local version of gulp as well as a global one.

Adding this line should fix your issue

RUN npm i gulp
nicovank
  • 3,157
  • 1
  • 21
  • 42
  • 2
    Has a bug with install gulp inside docker, use gulp-cli instead. `npm ERR! code E404 npm ERR! 404 Not Found: natives@https://registry.npmjs.org/natives/-/natives-1.1.4.tgz ` – Bernardo Loureiro May 26 '18 at 01:37