Skip to main content
Version: 5.6

Docker Compose

Docker Compose for Standard Installations

This page contains several Docker Compose examples for different use cases.

OPC Router Runtime

The OPC Router Runtime image includes a MongoDB.

services:
opc-router:
image: opcrouter/runtime:latest
restart: unless-stopped
ports:
# Ports for legacy redundancy or OPC servers must be additionally enabled.
# For 5 OPC UA servers, this could look like this:
# - "49420-49424:49420-49424"
# The default port for legacy redundancy is 49954.
# - "49954:49554"
- "8080:8080"
environment:
- OR_I_ACCEPT_EULA=true
- INITIAL_USERNAME=<username>
- INITIAL_PASSWORD=<password>
volumes:
- opcrouter-data:/data
- opcrouter-logs:/var/log/opcrouter
volumes:
opcrouter-data:
opcrouter-logs:

OPC Router Service

Unlike the runtime image, the OPC Router Service image does not contain an internal MongoDB. Therefore, an external MongoDB must be connected.

services:
opc-router:
image: opcrouter/service:latest
restart: unless-stopped
ports:
# Ports for legacy redundancy or OPC servers must also be enabled.
# For 5 OPC UA servers, this could look like this:
# - "49420-49424:49420-49424"
# The default port for legacy redundancy is 49954.
# - "49954:49554"
- "8080:8080"
environment:
- OR_I_ACCEPT_EULA=true
- INITIAL_USERNAME=<nuzername>
- INITIAL_PASSWORD=<passwort>
# The connection string for the database connection
- OR_DATABASE_CONNECTION=<mongodb connection-string="">
volumes:
- opcrouter-data:/data
- opcrouter-logs:/var/log/opcrouter
volumes:
opcrouter-data:
opcrouter-logs:

Docker Compose for Siemens Industrial Edge

services:
opcrouter:
depends_on:
- opcrouter-database
image: &#x27;opcrouter/service:5.2.5007.143&#x27;
restart: unless-stopped
entrypoint:
- /bin/bash
- &#x27;-c&#x27;
- |
json=$$(cat &quot;/cfg-data/schema.json&quot;)
while [[ $$json =~ \&quot;([^\&quot;]+)\&quot;:\s*\&quot;(([file://.|[%5e/%22%5d)*)/%22|/%22(%5b%5e/%22%5d+)/%22:/s*(%5b%5e,%7d]\\.|[^\&quot;])*)\&quot;|\&quot;([^\&quot;]+)\&quot;:\s*([^,}]+) ]]; do
if [[ $${BASH_REMATCH[2]} ]]; then
key=&quot;$${BASH_REMATCH[1]}&quot;
value=&quot;$${BASH_REMATCH[2]}&quot;
else
key=&quot;$${BASH_REMATCH[4]}&quot;
value=&quot;$${BASH_REMATCH[5]}&quot;
fi
if [[ $$value =~ ^\&quot;(.*)\&quot;$ ]]; then
value=&quot;$${BASH_REMATCH[1]}&quot;
fi
unescaped_key=$$(echo $$key | sed &#x27;s/\\\\/\\/g&#x27; | sed &#x27;s/\\&quot;/&quot;/g&#x27;)
unescaped_value=$$(echo $$value | sed &#x27;s/\\\\/\\/g&#x27; | sed &#x27;s/\\&quot;/&quot;/g&#x27;)
eval export $$unescaped_key=&#x27;$$unescaped_value&#x27;
json=$$(echo &quot;$$json&quot; | sed &quot;s/\&quot;$$key\&quot;:\(\&quot;[^\&quot;]*\&quot;\|[^,}]*\),\\?//&quot;)
done
/init
environment:
OR_DATABASE_CONNECTION_STRING: &#x27;mongodb://opcrouter-database:27017&#x27;
OR_DISABLE_AUTH: &#x27;true&#x27;
OR_I_ACCEPT_EULA: &#x27;true&#x27;
WEB_BASE_PATH: /opcrouter
volumes:
- &#x27;opc-router-data:/data&#x27;
- &#x27;opc-router-logs:/var/log/opcrouter&#x27;
- &#x27;./publish/:/publish/&#x27;
- &#x27;./cfg-data/:/cfg-data/&#x27;
mem_limit: 2gb
networks:
- proxy-redirect
- internal
logging:
options:
max-size: 20m
max-file: &#x27;5&#x27;
driver: json-file
opcrouter-database:
image: &#x27;mongo:4.4.29-focal&#x27;
restart: always
entrypoint:
- /bin/bash
- &#x27;-c&#x27;
- |
if [ -f /data/db/mongod.lock ]; then
echo &quot;[DB Initialization] Existing MongoDB database detected&quot;
echo &quot;[DB Initialization] Setting owner for database folder&quot;
chown -R mongodb:mongodb /data/db
mongod --replSet rs0 &gt; /dev/null &amp;
max_attempts=30
attempts=0
echo &quot;[DB Initialization] Waiting for MongoDB to be available...&quot;
while [[ $$attempts -lt $$max_attempts ]];
do
output=$$(mongo --quiet --eval &#x27;var result = db.runCommand({ ping: 1 }); if (result.ok == 1) { print(&quot;OK&quot;); } else { print(&quot;NOT OK&quot;); }&#x27; 2&gt;&amp;1)
if [[ &quot;$$output&quot; == &quot;OK&quot; ]]; then
echo &quot;[DB Initialization] MongoDB is available&quot;
break
fi
echo &quot;[DB Initialization] Waiting for MongoDB to start... (Attempt $$((attempts + 1)) of $$max_attempts)&quot;
sleep 1
attempts=$$((attempts + 1))
done
echo &quot;[DB Initialization] Trying to reinitialize replica set&quot;
replica_config=&quot;{_id: \&quot;rs0\&quot;, members: [{ _id: 0, host: \&quot;127.0.0.1:27017\&quot; }]}, { force: true }&quot;
mongo --eval &quot;try { rs.initiate() } catch { rs.reconfig($${replica_config}) }&quot;
echo &quot;[DB Initialization] Reinitialization finished&quot;
echo &quot;[DB Initialization] Restarting MongoDB&quot;
mongod --shutdown
wait
docker-entrypoint.sh mongod --replSet rs0
else
echo &quot;[DB Initialization] No existing MongoDB database detected&quot;
chown -R mongodb:mongodb /data/db
docker-entrypoint.sh mongod --replSet rs0
fi
volumes:
- &#x27;opc-router-db:/data/db&#x27;
- &#x27;./publish/:/publish/&#x27;
- &#x27;./cfg-data/:/cfg-data/&#x27;
mem_limit: 2gb
networks:
- internal
logging:
driver: json-file
options:
max-size: 20m
max-file: &#x27;5&#x27;
networks:
proxy-redirect:
external:
name: proxy-redirect
internal:
internal: true
volumes:
opc-router-db: null
opc-router-logs: null
opc-router-data: null