Docker - Network
The description below provides you with the necessary steps to create a virtual network between two (or more) Docker container(s) that can be used as a base for a redundant or distributed project scenario.
The tutorial assumes, that you already configured the container
myFirstContainer
for your WinCC OA project,
containing your first redundancy partner.
When using WinCC OA as a virtualized docker container it might be beneficial to create a redundant configuration of your project environment. This guide will provide you with the necessary steps to create a redundant environment for using WinCC OA in Docker.
-
Create a new network
myNetwork
that is used for the communication between the WinCC OA projects.$ docker network create --driver=bridge --subnet=172.28.0.0/16 --ip-range=172.28.5.0/24 --gateway=172.28.5.254 myNetwork
-
Create a new container
mySecondContainer
that uses the networkmyNetwork
.$ docker run --name myNewContainer --hostname <HOSTNAME_IHRES_PROJEKTS> --network myNetwork -u <Benutzername>:<Benutzername> -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /etc/hosts:/etc/hosts -v /etc/localtime:/etc/localtime:ro <Dockerimage-Name>
The Docker image file used in the call above must be created using the Dockerfile provided by WinCC OA. A description on how to create your image file can be found in the chapter Docker Support. -
Add the existing container to the network
myNetwork
.$ docker network connect myNetwork myFirstContainer
Both, the containermyFirstContainer
as well as the containermySecondContainer
, are now part of the same networkmyNetwork
and can establish a connection via the Docker network interface.
To verify if the connection has been successfully established the following docker commands can be used:
- Ping your Docker container
-
To execute a ping command from one Docker container to the other the
exec
command can be used:docker exec -it <Docker image name> ping <IP address of your second container>
- Get IP address
-
To get the IP address of your Docker container the following
inspect
command can be used:docker inspect