Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Express app with Redis and nodemon development server

In this step we'll link a Redis container to the app from step 01.

Prerequisites

Install Docker on your system.

Install Docker Compose on your system.

  • Python/pip: sudo pip install -U docker-compose
  • Other: curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose; chmod +x /usr/local/bin/docker-compose

Setup

Run docker-compose build. It will

  • install nodemon globally in your container
  • install all dependencies from the package.json locally
  • expose port 3000 to the host
  • instruct the container to execute npm start on start up.

Start

Run docker-compose up to create and start both web and db container. The app should then be running on your docker daemon on port 3030 (On OS X you can use boot2docker ip to find out the IP address).

You should see a counter on the index page which will be incremented in Redis on every request. See app/routes/index.js to learn how to conect to Redis via enviroment variables exposed to the web container.

Notes on boot2docker

It appears that boot2docker (OS X, Windows) currently does not automatically sync the system clock with the host system after a host resumes from sleep. This becomes a problem due to the way nodemon detects file changes. That might cause it to go bananas, if the clocks on both systems are "too much" out of sync. Until this is fixed, you might use this workaround or simply do a manual sync via

/usr/local/bin/boot2docker ssh sudo ntpclient -s -h pool.ntp.org