Running Blocks in a Docker container

Blocks can run in a Docker container using the method described here, based on Debian 12. This article explains how to build and run Blocks as a Docker image. It assumes that you're familiar with Docker and that Docker is installed on the host system.

:!: This is an advanced and unsupported method of running Blocks. If you're not familiar with Docker and the terminal window, you are strongly advised to use our standard Linux server image instead. The Docker-based solution described here only supports the AMD64/x86-64 architecture.

Setting up a CodeMeter license server

A Docker container cannot directly access physical USB license key. Instead, you have two options:

  • Use a cloud based license. This assumes that your docker container has internet access. Contact PIXILAB for details.
  • Connect the license key to the host computer and make it available over the local network.

To allow a Docker container to access a physical license key connected to the host computer (or any other accessible computer running CodeMeter), the license must be shared over the network using the "Server Access" feature of CodeMeter.

The process of enabling the "Server Access" feature differs between Windows and Linux:

On Linux:

  1. Stop the CodeMeter service by typing service codemeter stop in a terminal window.
  2. Open /etc/wibu/CodeMeter/Server.ini in a text editor. sudo is required for making changes to the file.
  3. Scroll down to the row beginning with IsNetworkServer=. Change it from 0 (default) to 1. Save the file and close the editor.
  4. Start the CodeMeter service again by typing service codemeter start in a terminal window.

On Windows you may use either CodeMeter's Web Admin user interface, or the following command line method:

  1. Search for "CodeMeter command prompt" and launch it.
  2. Type codemeter /n+.

Building the Docker image from the Dockerfile

:!: When building the image, make sure there are no USB license keys connected to the computer. Otherwise, the build process may fail.

  1. Download the files required either using git or by selecting the ZIP file option.
  2. If you opted for th ZIP file, extract the ZIP and open the resulting folder in a terminal.
  3. Type docker build -t blocks . to build the image. This may take some time.

Running the image in a Docker container

To run the image in a Docker container, a few things have to be configured:

  • Port 8080 must be mapped to a port on the host system and a mount path for /home/blocks must be specified. /home/blocks contains the Blocks installation as well as the PIXILAB-Blocks-root. A Blocks server configuration file can also be placed here.
  • The USERID environment varaible must be set to match the UID of the owner of the /home/blocks volume on the host system. On Linux, type echo $UID in a terminal to see the current users UID. On Windows, use any UID. Please use a UID larger than or equal to 1000.
  • The TZ environment variable should be set to the correct time zone. Here is a list of valid TZ values.
  • The LICENSE_SERVER environment variable should be set to the address of the CodeMeter license server. (In some cases, this may not be required if the license server is running on the host computer, although this behaviour does not seem to be consistent across different platforms.)

:!: WARNING: localhost is not a valid LICENSE_SERVER address (at least when running the container in the default Bridge network mode)! localhost refers to localhost of the container, not the host computer. Instead, use the IP address or a DNS name, if available.

The previously downloaded and extracted archive contains a docker-compose.yml file. Modify the container configuration in this file according to the descriptions above, then simply run docker compose up to start a Blocks container. If everything is working, the Blocks editor should be accessible from http://the_host_address:the_host_port/edit.

Below is a sample docker-compose configuration:

services:
  blocks:
     image: blocks:latest
     init: true
     network_mode: bridge
     ports:
       - 8080:8080
     volumes:
        - /home/myuser/blocks-home:/home/blocks
     environment:
       - USERID=1000
       - LICENSE_SERVER=10.0.1.2
       - TZ=Europe/Stockholm

Running a different Blocks version

The startup script will download the latest version of Blocks to /home/blocks when the container is started. To use another version of Blocks, simply replace the Blocks executables in /home/blocks from the host system. The startup script will NOT download the latest Blocks version if another version is already present in /home/blocks.