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.

Note: Please be aware, that gaining proper knowledge of Docker, Docker networking and WinCC OA in general is advised before setting up a redundant system within your virtualized container environment.

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.

  1. 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
  2. Create a new container mySecondContainer that uses the network myNetwork.
    $ 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.
  3. Add the existing container to the network myNetwork.
    $ docker network connect myNetwork myFirstContainer
    Both, the container myFirstContainer as well as the container mySecondContainer, are now part of the same network myNetwork and can establish a connection via the Docker network interface.
After following the steps described above the two Docker container instances will use the same virtual network which enables these containers to communicate with each other and therefore use the redundancy and distributed options within your Docker environment.

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