Docker container with NodeJS
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

NodeJS container

Quick installation

  1. docker build --rm --no-cache=true -t nodejs .

  2. The docker build sometimes fail due to network errors etc. Repeat docker build --rm -t nodejs . until the build succeeds.

  3. Copy env.list.template to env.list and update. Do: set -a; . env.list

  4. Start a container without exposing port 1883 (a load balancer like haproxy is needed) and linking to a beservices (beservices has logging etc. Typically used for production but not necessary for development):

    docker run -t -i --restart="on-failure:10" \
    --link beservices:beservices --link mariadb:mariadb --env-file=env.list -h nodejs --name nodejs nodejs \
    /bin/bash -c "supervisord; export > /env; bash"

Start and expose port 1883 without linking to a beservices container (typically for development):

    docker run -t -i -p 1883:1883 --restart="on-failure:10" \
    --env-file=env.list -h nodejs --name nodejs1 nodejs \
    /bin/bash -c "supervisord; export > /env; bash"
  1. Install the node applications in the /apps folder

  2. Disconnect from the container with ctrl-p ctrl-q if you want to keep it running. exit will stop the container.

  3. Check the log files: docker logs nodejs

Install apps

Repos for apps should be cloned into /apps. It is handy to configure a machine account for git, see the github guide. Run ssh -T from the container to validate that SSH has been configured correctly.

Image backups

It is sometimes good to save a backup of the image.

>docker save nodejs > nodejs-dockcer.tar
>gzip nodejs-dockcer.tar
>docker load nodejs-docker.tar