Skip to main content
This section provides instructions for running ABBYY FineReader Engine 12 inside a Docker container. This scenario uses two containers:
  1. one container with ABBYY FineReader Engine
  2. one container with the Licensing Service
Implementing of this scenario increases the fault tolerance and ensures the continuous operation of all containers. If one of the containers fails, you can restart it without interrupting the other. An Online License, which connects to *.abbyy.com license server, is used for this scenario.
ABBYY Licensing Service can work with only one Online License at the same time.
You need:
  • an Online License token file
  • the password to the license token file
You need to fulfill the following conditions for using an Online License wherever ABBYY Licensing Service is installed:
  • Active Internet connection
  • Allowed connections to *.abbyy.com on port 443 (HTTPS)
  • GoDaddy Trusted Root Certification Authority contained in ca-certificates package (see details on the GoDaddy website)
To run ABBYY FineReader Engine 12 in Docker container:
  1. Download and install Docker and Docker Compose on your machine.
  2. Create an empty directory and put into it:
  • Dockerfile_ls — a Dockerfile for container with the Licensing Service (see its listing below)
Dockerfile_ls is intended for building a container that will be working with only one container built from Dockerfile_worker . Do not configure multiple replicas of container with ABBYY FineReader Engine to work with a single Licensing Service.
Note: This container runs the Licensing Service with /standalone key. With this key, the Licensing Service works as a foreground process, which is the best practice for working in Docker containers.
  • Dockerfile_worker — a Dockerfile for container with ABBYY FineReader Engine (see its listing below)
  • wrapper.sh — a command-line script for running the sample and displaying its results in the console (see its listing below)
  • docker-compose.yml — a configuration of Docker Compose (see its listing below)
Note that for container with ABBYY FineReader Engine, we set the /dev/shm size manually in docker-compose.yml . We recommend setting it to at least 1GB.
  • ABBYY FineReader Engine 12 Distributive file (FREngine-Linux-%BUILD_ID%.sh)
  • Online License token file
  1. Specify the parameters of your license in the following lines of docker-compose.yml:
args:
- license_token=SWRRXXXXXXXXXXXXXXXXXXXX.ABBYY.ActivationToken
- license_password=your_license_password
  1. To build and run the containers, use the following command:
docker-compose up
The results of sample will be displayed in the console.
You may customize the default arguments of the CommandLineInterface (CLI) code sample by editing the following line of docker-compose.yml :
command: ["-if /app/Demo.tif -f TextUnicodeDefaults -of /app/Test.txt"]
See details for the CLI arguments in the Code Samples Library.
Dockerfile_ls
# Stage 1.
# From this part we take the Licensing Service
FROM ubuntu:bionic as builder
 
# Install the required packages
RUN DEBIAN_FRONTEND=noninteractive \
    apt update \
    && apt install --no-install-recommends --yes \
    bash \
    gzip \
    tar \
    coreutils \
    gettext-base
COPY FRE*.sh /tmp/FRE12.sh
 
# Install ABBYY FineReader Engine
RUN chmod +x /tmp/FRE12.sh && /tmp/FRE12.sh -- \
    --install-dir "/opt/ABBYY/FREngine12" \
    --skip-local-license-activation
 
# Stage 2. Take a clean image
# Prepare it for using the Licensing Service
FROM ubuntu:bionic
 
# Install the required packages
RUN DEBIAN_FRONTEND=noninteractive \
    apt update \
    && apt install --no-install-recommends --yes \
    ca-certificates \
    bash \
    libc6 \
    libgcc-8-dev \
    libstdc++-8-dev
# Copy the Licensing Service from stage 1
COPY --from=builder /usr/local/bin/ABBYY/SDK/12/Licensing /usr/local/bin/ABBYY/SDK/12/Licensing/
COPY --from=builder /usr/local/lib/ABBYY/SDK/12/Licensing /usr/local/lib/ABBYY/SDK/12/Licensing/
 
# Create a folder for working of the Licensing Service 
RUN mkdir /var/lib/ABBYY/SDK/12/Licenses -p && chmod 755 /var/lib/ABBYY/SDK/12/Licenses
 
ENV LD_LIBRARY_PATH=/usr/local/lib/ABBYY/SDK/12/Licensing
 
EXPOSE 3023
 
ENTRYPOINT ["/usr/local/bin/ABBYY/SDK/12/Licensing/LicensingService", "/standalone"]
Dockerfile_worker
# Stage 1. 
# From this part we take a directory with ABBYY FineReader Engine installed and the compiled sample
# Use the official GCC container to get all development tools. 
# We use 8th version of GCC as an example only because it is the default GCC in ubuntu bionic
# you can use any version starting from 4.8
FROM gcc:8 as builder
 
ARG license_token
ARG license_password
ARG service_address
# Copy the license token file and use it to generate the correct SamplesConfig.h 
# during the installation process
COPY ${license_token} /tmp/${license_token}
 
COPY FRE*.sh /tmp/FRE12.sh
 
# Install ABBYY FineReader Engine 12 and build the sample
RUN chmod +x /tmp/FRE12.sh && /tmp/FRE12.sh -- \
    --install-dir "/opt/ABBYY/FREngine12" \
    --license-path "/tmp/${license_token}" \
    --license-password "${license_password}" \
    --service-address "${service_address}" \
    --developer-install
WORKDIR /opt/ABBYY/FREngine12/Samples/CommandLineInterface
RUN make
# To copy entire folders at the next stage, remove all unnecessary files from
# distribution kit of installed ABBYY FineReader Engine
RUN rm /opt/ABBYY/FREngine12/Bin/libProtection.Developer.so
 
# Stage 2. Take a clean image 
# Prepare it for using ABBYY FineReader Engine
# At this stage we use a minimalistic ubuntu image without development tools
FROM ubuntu:bionic
 
# Install the required packages 
RUN DEBIAN_FRONTEND=noninteractive \
    apt update \
    && apt install --no-install-recommends --yes \
    ca-certificates \
    bash \
    libc6 \
    libglib2.0-0 \
    libgcc-8-dev \
    libstdc++-8-dev \
    zlib1g \
    libx11-6 \
    libfreetype6 \
    libxext-dev \
    libice-dev \
    libsm-dev \
    locales \
    && locale-gen en_US.UTF-8
# Copy ABBYY FineReader Engine from stage 1
COPY --from=builder /opt/ABBYY/FREngine12/Bin /opt/ABBYY/FREngine12/Bin
COPY --from=builder /opt/ABBYY/FREngine12/Data /opt/ABBYY/FREngine12/Data
# Create a folder for working of the Licensing Service and cache storage
# Copy the license token file into this folder
COPY --from=builder /var/lib/ABBYY/SDK/12/Licenses/*.ABBYY.ActivationToken /var/lib/ABBYY/SDK/12/Licenses/
# Copy the compiled sample and demo image
COPY --from=builder /opt/ABBYY/FREngine12/Samples/CommandLineInterface/CommandLineInterface /app/
COPY --from=builder /opt/ABBYY/FREngine12/Samples/SampleImages/Demo.tif /app/
ENV LD_LIBRARY_PATH=/opt/ABBYY/FREngine12/Bin
# wrapper.sh - a script for launching the sample and displaying the result in the console
COPY ./wrapper.sh /wrapper.sh
RUN chmod +x /wrapper.sh
ENTRYPOINT ["/wrapper.sh"]
#!/bin/bash
 
# Launch sample
/app/CommandLineInterface $1
status=$?
if [ $status -ne 0 ]; then
  echo "Failed to launch app: $status"
  exit $status
fi
cat ${1##*-of}
echo "Done"
version: '3'
services:
  worker:
    build:
      context: .
      dockerfile: Dockerfile_worker
      args:
        - license_token=SWRRXXXXXXXXXXXXXXXXXXXX.ABBYY.ActivationToken
        - license_password=your_license_password
        - service_address=ls
    depends_on:
      - ls
    shm_size: 1g
    command: ["-if /app/Demo.tif -f TextUnicodeDefaults -of /app/Test.txt"]
    restart: on-failure
  ls:
    build:
      context: .
      dockerfile: Dockerfile_ls
    restart: on-failure

See also

Installing the Licensing Service on Linux Licensing Activation