Connect Node-RED Docker container to host OPC UA server

Hi, I've developed a Node-RED dashboard that connects to an OPC UA server. using the OPC UA nodes. I'd like to dockerise this so i've been following some tutorials to build my container and map the docker port to 1880 to the host port 1880.

https://nodered.org/docs/getting-started/docker

This works fine but i can't seem to connect to my OPC UA server anymore through my to my docker container. Does anyone know how to map a port from the host to a docker conatiner so Node-RED can see the server?

my server is located at opc.tcp://localhost:49500

To build my docker container, map Node-RED to port 1880 and have persistant data I use the following command:

docker run -it -p 1880:1880 -v node_data:/data --name OPC_UA nodered/node-red

I've tried adding the port using an additional -p tag but this doesn't seem to work since my host sever is using that port. Using the next port also doesn't seem to work - although on compile there are no errors.

docker run -it -p 1880:1880 -p 49500:49501 -v node_data:/data --name OPC_UA nodered/node-red

Any help would be fantastic!
Ollie

Where is the OPCUA server running ? If it's on the host then it isn't at localhost from the containers point of view... You shouldn't need to map ports for the container to get outbound connection - but you will need to use the correct host address to connect to.

(or is the OPCUA server in another container ?)

Hi, The OPC Server is actually a LabVIEW VI running on the same machine as docker. Ther server endpoint URL is opc.tcp://HYDROGEN:49500. So i think i need to somehow map this port to allow my docker container to see it and also to send any user imports from Node-RED back to ther OPC UA Server?

Hi no - the port should be OK - it's the name the container won't now about - try replacing HYDROGEN by the actual IP address.

Fanatstic - thats fixed it! me being a muppet!
Thank you!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.