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:

  • Image successfully builds but won't push due to auth credentials
  • How to copy files from Windows host to Docker container
  • run docker exec on possibly stopped container, so that it would execute without error
  • How do I change permissions in a docker volume?
  • How to list images in docker registry being on registry server?
  • Linux “Perf” tool cannot run inside docker images?
  •    {
          "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


  • dockerized django: static tag in templates not detecting the present static files
  • Change Ubuntu locale in Docker
  • Deis Workflow v2.9.0 deis pull deis/example-go -a <app-name> Error
  • docker pentaho mysql driver issue
  • Docker run java app
  • Restarting machines in a docker swarm on AWS
  • 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.