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 sonarqube checkdependency plugin
  • Docker Volume another disk
  • What's wrong with this dockerfile
  • Fetching git behind proxy in docker container
  • Running an iPython notebook server on an EC2 Ubuntu instance via Docker
  • Unable to start a Docker container through Remote Docker Java API
  •    {
          "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


  • Environment variable in PHP-docker container
  • How to enable secure communication between Docker Containers in a Swarm?
  • How do I know whether “init” or “systemd” controls the docker?
  • Colocate docker containers using docker swarm
  • docker-compose volume not appearing in container
  • Docker quickstart terminal not opening
  • 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.