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

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  softplc-containers
    
  3. Navigate to the softplc-containers directory. This directory should contain the following:

    $ ls
    build.sh  docker  README.md
    
  4. Run the build.sh script, located in this directory, to build the CODESYS* Docker* images:

    /bin/bash build.sh
    

    Tip

    You can change the version of the CODESYS* components installed by editing their Dockerfiles. Edit variable CDS_VERSION in Dockerfile docker/Dockerfile.controlruntime and variable EDGE_VERSION in Dockerfile docker/Dockerfile.gateway. Supported version of CODESYS* are (3.5.15.*, 3.5.16.*, 4.5.0.0).

    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* Linux* runtime

    codesys-edge-gateway.tar

    Contains the CODESYS* Edge Gateway

Execute CODESYS Linux Runtime 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. 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
    
  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        4.5.0.0                 7d6256f52029   About a minute ago   258MB
    
  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:4.5.0.0
    

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* image:

    $ 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   4.5.0.0                 acfa543d8f20   About a minute ago   161MB
    
  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* Linux* 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* Linux* runtimes active on the same Docker* network will be displayed during a network scan.