Bower dependicies with postinstall on Docker

It is possible to install bower dependicies using postinstall in package.json on docker with docker-compose?

package.json file:

  • Docker Toolbox SSH Login
  • Docker portability issues with locally saved images
  • gitlab in docker behind traefik proxy fails (usually)
  • Running java command with Docker exec fails with “no such file or directory”
  • Docker - one process per container?
  • docker double service names
  •    {
          "name": "mongocrud",
          "version": "0.0.0",
          "private": true,
          "scripts": {
            "start": "node ./config/server.js",
            "postinstall": "node ./node_modules/bower/bin/bower install",
            "test": "mocha"
          "dependencies": {


    FROM node:7.7.2-alpine
    WORKDIR /application
    COPY package.json .
    COPY bower.json .
    COPY .bowerrc .
    RUN npm install -g bower
    RUN npm install
    COPY . .
    EXPOSE 3000
    CMD ["npm", "start"]


    version: '3'
            image: mongo:3.4.4
            command: mongod
            container_name: mongo-container
                - 27017:27017
             build: .
             container_name: express-container
                - 3000:3000
             working_dir: /application
                - mongodb
             command: npm start

    And after use docker-compose up application works fine but missing bower dependicies, can I fix that?


    This I found in console after docker-compose up:

    npm WARN lifecycle mongocrud@0.0.0~postinstall: cannot run in wd %s %s (wd=%s) mongocrud@0.0.0 node ./node_modules/bower/bin/bower install /application


  • Rspec test failing against Docker container
  • Docker: data volume container is not instantiated with `docker create` command
  • Docker - Rails app cannot connect to linked Postgres container (doesn't seem to be running)
  • Can't acces docker container by IP address
  • Debian httpredir mirror system unreliable/unusable in Docker?
  • How to start muli process in background with supervisor on Docker
  • One Solution collect form web for “Bower dependicies with postinstall on Docker”

    Change node ./node_modules/bower/bin/bower install to bower install --allow-root in postinstall script. The --allow-root is to prevent you from permission errors.

    Or you can remove the postinstall script and add RUN bower install --allow-root after RUN npm install in the Dockerfile.

    And bower requires git to work, you have to install git first in your Dockerfile.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.