Attention

You are viewing an older version of the documentation. The latest version is v3.3.

Microservice: CODESYS Linux Runtime & CODESYS Edge Gateway

The following section describes how to integrate a containerized CODESYS SoftPLC. These instructions assume an existing ECI installation, familiarity with building Docker containers and running the CODESYS Software PLC.

The following section is applicable to:

../../_images/linux4.png

Prerequisites: CODESYS Containers

  1. Download the CODESYS Control for Linux SL package (CODESYS Control for Linux SL x.x.x.x.package) from the following website:

    ../../_images/0212.png
  2. Optional: If desired, download the CODESYS Edge Gateway for Linux package (CODESYS Edge Gatway for Linux x.x.x.x.package) from the following website:

    Note

    There is an option to skip building the CODESYS Edge Gateway for Linux microservice, as such, this step is optional.

    ../../_images/edge_gateway_website.png

Building: CODESYS Containers

The following steps detail how to build Docker images which contain CODESYS components.

  1. If not already completed, follow section Prepare the Build System for Microservices to prepare the build system.

  2. Open a terminal on the build system and navigate to the extracted Dockerfiles directory. The contents of this directory should be as follows:

    $ ls
    application-containers  bpf  display-containers  softplc-containers
    
  3. Navigate to the softplc-containers directory. The contents of this directory should be as follows:

    $ ls
    build.sh  codesys-control  codesys-control-apploader  codesys-edge-gateway  codesys_packages  README.md
    
  4. Copy CODESYS Control for Linux SL x.x.x.x.package downloaded earlier into the codesys_packages directory.

  5. Optional: Copy CODESYS Edge Gatway for Linux x.x.x.x.package downloaded earlier into the codesys_packages directory.

  6. Execute the build.sh script located in this directory to build the CODESYS Docker images:

    /bin/bash build.sh
    

    After the build has completed successfully, there will be Docker images that have generated and tarballed. Each of them vary:

    Docker Image archive name

    Description of Docker Image

    codesys-control.tar

    Docker image which contains only the CODESYS runtime.

    codesys-control-apploader.tar

    Docker image which contains the CODESYS runtime as well as functionality to run a CODESYS workload.

    codesys-edge-gateway.tar

    Docker image which contains the CODESYS Edge Gateway.

Executing: CODESYS Linux Runtime Containers

The following section is applicable to:

../../_images/target5.png
  1. Ensure that the Docker daemon is active. Run the following command to restart the Docker daemon.

    Warning

    All running Docker containers will also restart.

    $ systemctl restart docker
    

    The status of the Docker daemon can be verified with the following command:

    $ systemctl status docker
    
  2. Copy the Docker images created earlier to the target system.

  3. Load the copied Docker images by performing the following commands:

    $ docker load < codesys-control.tar
    $ docker load < codesys-control-apploader.tar
    
  4. Check which Docker images are present on the target system with the following command:

    $ docker images
    

    The CODESYS images that were loaded should be present in the list. Note the names and tags of these images for use in the following steps.

    For example, on your system the output is as follows:

    $ docker images
    REPOSITORY                  TAG                 IMAGE ID            CREATED              SIZE
    codesys-control-apploader   v1.5                c2a503766b98        2 minutes ago        207MB
    codesys-control             v1.5                959056a52734        2 minutes ago        201MB
    
  5. Start the container with the following command, where <container> and <tag> correspond to the values on the target system:

    $ docker run --cap-add=SYS_PTRACE --network host <container>:<tag>
    

    For example, on our system we start the codesys-control container:

    $ docker run --cap-add=SYS_PTRACE --network host codesys-control:v1.5
    

Executing: CODESYS Edge Gateway Container

The following section is applicable to:

../../_images/target5.png
  1. Ensure that the Docker daemon is active. Run the following command to restart the Docker daemon.

    Warning

    All running Docker containers will also restart.

    $ systemctl restart docker
    

    The status of the Docker daemon can be verified with the following command:

    $ systemctl status docker
    
  2. Copy the Docker image created earlier to the target system.

  3. Load the copied Docker image by performing the following command:

    $ docker load < codesys-edge-gateway.tar
    
  4. Check which Docker images are present on the target system with the following command:

    $ docker images
    

    The CODESYS image loaded earlier should be present in the list. Note the name and tag of the image for use in the following steps.

    For example, on our system the output is as follows:

    $ docker images
    REPOSITORY                  TAG                 IMAGE ID            CREATED              SIZE
    codesys-edge-gateway        v1.5                7b651e1bc6f2        About a minute ago   142MB
    
  5. This step is optional. To run the CODESYS Edge Gateway in a separate Docker network called codesys, create it first by performing the following command:

    $ docker network create codesys
    
  6. The CODESYS Edge Gateway must be reachable from external host over the port tcp/1217, hence the parameter -p 1217:1217 is necessary. Start the CODESYS Edge Gateway container by performing the following command:

    $ docker run -d --rm \
      --name codesys-edge-gateway \
      --hostname docker-edge-gateway \
      -p 1217:1217 \
      codesys-edge-gateway
    

    Note: If a Docker network had been created earlier, add the parameter --network codesys to connect the container to this network:

    $ docker run -d --rm \
      --name codesys-edge-gateway \
      --hostname docker-edge-gateway \
      --network codesys \
      -p 1217:1217 \
      codesys-edge-gateway
    
  7. It is possible to view all the active CODESYS runtimes on the Docker network using the CODESYS IDE. Refer to section CODESYS IDE Installation for installing the CODESYS IDE.

    The following section is applicable to:

    ../../_images/windows3.png

    Using the CODESYS IDE, connect to the CODESYS Edge Gateway by using the target system IP address and standard port 1217. If any CODESYS runtimes are active on the same Docker network, they will be visible when performing a network scan.