Attention

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

Microservice: CODESYS Linux Runtime and CODESYS Edge Gateway

The following section describes the procedure to integrate a containerized CODESYS* SoftPLC. These instructions assume that you have an existing ECI installation and you are familiar with building Docker containers and running the CODESYS Software PLC.

The following section is applicable to:

../../_images/linux1.png

CODESYS Containers: Prerequisites

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

    Important

    Only CODESYS Control for Linux SL versions 3.5.16.20 and older, or 4.5.0.0 and newer are compatible with container environments. Versions 4.0.x.x - 4.4.x.x do not work in a container correctly!

    ../../_images/022.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:

    ../../_images/032.png

    Note: There is an option to skip building the CODESYS Edge Gateway for Linux microservice, and this step is optional.

Build CODESYS Containers

Do the following to build Docker* images that contain CODESYS components:

  1. If not already completed, prepare the build system.

  2. Open a terminal on the build system and navigate to the extracted Dockerfiles directory. This directory should contain the following:

    $ ls
    application-containers  bpf  display-containers  softplc-containers
    
  3. Navigate to the softplc-containers directory. This directory should contain the following:

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

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

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

    /bin/bash build.sh
    

    After the build has completed successfully, Docker images would have been generated and tarballed. Each of them vary:

    Docker Image Archive Name

    Description of Docker Image

    codesys-control.tar

    Contains only the CODESYS runtime

    codesys-control-apploader.tar

    Contains the CODESYS runtime and the functionality to run a CODESYS workload

    codesys-edge-gateway.tar

    Contains the CODESYS Edge Gateway

Execute CODESYS Linux Runtime Containers

The following section is applicable to:

../../_images/target4.png
  1. Install Docker if not already done.

  2. Ensure that the Docker daemon is active. Run the following command to restart the Docker daemon:

    Warning: All Docker containers that are currently running will also restart.

    $ systemctl restart docker
    
  3. Verify the status of the Docker daemon:

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

  5. Load the copied Docker image:

    $ docker load < codesys-control.tar
    $ docker load < codesys-control-apploader.tar
    
  6. Check the Docker images that are present on the target system:

    $ docker images
    

    The CODESYS images that were loaded should be present in the list. Note down the names and tags of these images.

    Here is a sample output:

    $ 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
    
  7. Start the container. Note that <container> and <tag> correspond to the values on the target system:

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

    For example, here is the command to start the codesys-control container:

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

Execute CODESYS Edge Gateway Container

The following section is applicable to:

../../_images/target4.png
  1. Install Docker if not already done.

  2. Ensure that the Docker daemon is active. Restart the Docker daemon:

    Warning: All running Docker containers will also restart.

    $ systemctl restart docker
    
  3. Verify the status of the Docker daemon:

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

  5. Load the copied Docker images:

    $ docker load < codesys-edge-gateway.tar
    
  6. Check the Docker images that are present on the target system:

    $ docker images
    

    The CODESYS image loaded earlier should be present in the list. Note down the names and tags of these images.

    Here is a sample output:

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

    $ docker network create codesys
    
  8. The CODESYS Edge Gateway must be reachable from external host over the port tcp/1217, hence the parameter -p 1217:1217 is necessary. Run the following commands to start the CODESYS Edge Gateway container:

    $ 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
    
  9. You can view all active CODESYS runtimes on the Docker network using the CODESYS IDE. Refer to Install CODESYS IDE for installing the CODESYS IDE.

    The following section is applicable to:

    ../../_images/windows3.png

    With the CODESYS IDE, connect to the CODESYS Edge Gateway using the IP address of the target system and standard port 1217. Any CODESYS runtimes active on the same Docker network will be displayed during a network scan.