Docker /bin/bash: nodemon: command not found

I am trying to mount my working node code from my host into a docker container and run it using nodemon using docker-compose.
But container doesn’t seems to be able to find nodemon.
Note: My host machine does not has node or npm installed on it.

Here are the files in the root folder of my project (test). (This is only a rough draft)

  • How does docker's `net=host` setting work, and how can I do something similar with e.g. VirtualBox?
  • Assign one docker instance to each client
  • ssh key generation using dockerfile
  • docker-sync excludes are not excluded?
  • Docker port binding not working as expected
  • Trouble running UPNP on Docker
  • Dockerfile

    FROM surenderthakran/nodejs:v4
    ADD . /test
    WORKDIR /test
    RUN make install
    CMD make run


    PWD:=$(shell pwd)
    export PATH:= $(PWD)/node_modules/.bin:$(PWD)/bin:$(PATH)
    DOCKER:=$(shell grep docker /proc/1/cgroup)
        @echo Running make install......
        @npm config set unsafe-perm true
        @npm install
        @echo Running make run......
    # Check if we are inside docker container
    ifdef DOCKER
        @echo We are dockerized!! :D
        @nodemon index.js
        @nodemon index.js
    .PHONY: install run


        build: .
        command: make run
            - .:/test
            NODE_ENV: dev
            - "17883:17883"
            - "17884:17884"


      "name": "test",
      "version": "1.0.0",
      "description": "test",
      "main": "index.js",
      "dependencies": {
        "express": "^4.13.3",
        "nodemon": "^1.8.0"
      "devDependencies": {},
      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1"
      "keywords": [
      "author": "test",
      "license": "ISC"


    'use strict';
    var express = require('express');

    I build my image using docker-compose build. It finishes successfully.
    But when I try to run it using docker-compose up, I get:

    Creating test_app_1...
    Attaching to test_app_1
    app_1 | Running make run......
    app_1 | We are dockerized!! :D
    app_1 | /bin/bash: nodemon: command not found
    app_1 | make: *** [run] Error 127
    test_app_1 exited with code 2
    Gracefully stopping... (press Ctrl+C again to force)

    Can anyone please advice?

    Note: The Dockerfile for my base image surenderthakran/nodejs:v4 can be found here:

  • How to create a Jenkins job and/or user from a dockerfile?
  • Installing docker on azure virtual machine windows 10
  • Docker with vnc or vagrant with vnc for graphical aplications
  • Docker doesn't resolve hostname
  • Docker container not started because rabbit is out of disc space
  • Docker on Windows Server 2016 TP4 Downloading git in container through powershell
  • One Solution collect form web for “Docker /bin/bash: nodemon: command not found”

    The issue has been resolved. The issue boiled down to me not having node_modules in the mounted volume.

    Basically, while doing docker-compose build the image was build correctly with the actual code being added to the image and creating the node_modules folder by npm install in the project root. But with docker-compose up the code was being mounted in the project root and it was overriding the earlier added code including the newly created node_modules folder.

    So as a solution I compromised to install nodejs on my host and do a npm install on my host. So when the code my being mounted I still got my node_modules folder in my project root because it was also getting mounted from my host.

    Not a very elegant solution but since it is a development setup I am ready for the compromise. On production I would be setting up using docker build and docker run and won’t be using nodemon anyways.

    If anyone can suggest me a better solution I will be greatful.


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