Skip to content

Run Nodes in docker containers for test

Mikael Håkansson edited this page Jul 23, 2018 · 12 revisions

These instructions is suited for running a bunch of nodes in separate containers.

Create a docker file

  1. Create a file called "Dockerfile" with the following content:
FROM node:8
RUN npm install microservicebus-node
COPY entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
root@microServiceBus-gccBuild:/home/msbadmin/mikael/docker#
  1. Create a file called "entrypoint.sh" with the following content:
#!/bin/sh
echo "$1"

cd node_modules/microservicebus-node
node start -c $1 -n $2
  1. Create a docker image:
docker build -t msb
  1. Create your node and generate a code
  2. Create a node container:
docker run -d --name [NODENAME] msb [CODE] [NODENAME]
# Eg.
docker run -d --name node-00001 msb QQIN643B node-00001
  1. To stop the container:
docker stop node-00001

# Stop all containers:
docker stop $(docker ps -q)
  1. To start the container:
docker start node-00001

# Start all containers:
docker start $(docker ps -a -q)
Clone this wiki locally