Skip to content

Docker containers

This article explains how to create a Docker image with an application built with the IDLive Face SDK.

Build image

Create a Dockerfile and put IDLive Face SDK and your application next to it. Your work directory should look like this (using a Python application as an example):

idliveface/
app.py
Dockerfile

Now let's write the Dockerfile. First you need a base image, you can use any suitable one:

FROM ubuntu:20.04
FROM python:3.8-slim
FROM azul/zulu-openjdk:11

Next you need to copy data, libs directories from the SDK and also copy directory with license. Since 1.45 license provided in a separate package, for simplicity assuming its content was preliminary copied to idliveface/license directory. Before 1.45 license was already packaged in idliveface/license directory. Copying looks as follows:

ENV IDLIVEFACE_HOME=/app/idliveface

COPY idliveface/data ${IDLIVEFACE_HOME}/data/
COPY idliveface/libs ${IDLIVEFACE_HOME}/libs/
COPY idliveface/license ${IDLIVEFACE_HOME}/license/

IDLIVEFACE_HOME environment variable can be used to locate the SDK from the scripts and applications.

Afterwards copy your application and put it into the CMD instruction:

ENV LD_LIBRARY_PATH=${IDLIVEFACE_HOME}/libs

COPY app /app/
CMD ["/app/app"]
ENV PYTHONPATH=${IDLIVEFACE_HOME}/libs/python

COPY app.py /app/
CMD ["python3", "/app/app.py"]
ENV LD_LIBRARY_PATH=${IDLIVEFACE_HOME}/libs
ENV CLASSPATH=${IDLIVEFACE_HOME}/libs/java/*

COPY app.jar /app/
CMD ["java", "-jar", "/app/app.jar"]

Note the additional environment variables, they help the language runtimes to locate IDLive Face libraries.

Install license

IDLive Face SDK requires an active license to be able to load. For the license to function in the container you need to install a special system service (RTE, or Run-time Environment).

License type

This manual explains how to use an admin mode license that requires an additional application to run in the container. You can instead use a user mode license which does not have such a requirement. But we advise you not to use the user mode licenses, as they have stability issues when running inside the container.

Add these lines to the Dockerfile:

RUN mkdir aksusbd \
 && tar zxf ${FACESDK_HOME}/license/rte/aksusbd.tar.gz -C aksusbd --strip-components=1 \
 && (cd aksusbd && ./dinst) \
 && /etc/init.d/aksusbd stop \
 && rm -rf aksusbd /var/hasplm/storage/ \
 && chmod a+rwX -R /var/hasplm/ /etc/hasplm/

This will install the RTE package and configure it to be used in the container. Now before you start your application you need to:

  1. start the RTE
  2. install the license key

You need to do it on the container's startup, you can not do these steps in the Dockerfile. For that we need to use a special entrypoint script. Create a file named entrypoint.sh with this content:

#!/bin/sh
set -e

hasplmd_x86_64 -s && sleep 3
(cd "${IDLIVEFACE_HOME}/license" && ./install_license_linux rte/*.v2c)

exec "$@"

Then copy it to the image and set it as an entrypoint. Note that you need to make the script runnable, either manually or in the Dockerfile:

COPY entrypoint.sh /app/
RUN chmod a+x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

License Manager startup timeout

If you have this error when you start your container:

Error: License Manager is not running

then try to increase the sleep time in the entrypoint.sh script.

Full Dockerfile

For C++ application
FROM ubuntu:20.04

# IDLive Face SDK
ENV IDLIVEFACE_HOME=/app/idliveface

COPY idliveface/data ${IDLIVEFACE_HOME}/data/
COPY idliveface/libs ${IDLIVEFACE_HOME}/libs/
COPY idliveface/license ${IDLIVEFACE_HOME}/license/

# The application
ENV LD_LIBRARY_PATH=${IDLIVEFACE_HOME}/libs

COPY app /app/
CMD ["/app/app"]

# The license
RUN mkdir aksusbd \
 && tar zxf ${FACESDK_HOME}/license/rte/aksusbd-*.tar.gz -C aksusbd --strip-components=1 \
 && (cd aksusbd && ./dinst) \
 && /etc/init.d/aksusbd stop \
 && rm -rf aksusbd /var/hasplm/storage/ \
 && chmod a+rwX -R /var/hasplm/ /etc/hasplm/

COPY entrypoint.sh /app/
RUN chmod a+x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

Download

For Python application
FROM python:3.8-slim

# IDLive Face SDK
ENV IDLIVEFACE_HOME=/app/idliveface

COPY idliveface/data ${IDLIVEFACE_HOME}/data/
COPY idliveface/libs ${IDLIVEFACE_HOME}/libs/
COPY idliveface/license ${IDLIVEFACE_HOME}/license/

# The application
ENV PYTHONPATH=${IDLIVEFACE_HOME}/libs/python

COPY app.py /app/
CMD ["python3", "/app/app.py"]

# The license
RUN mkdir aksusbd \
 && tar zxf ${FACESDK_HOME}/license/rte/aksusbd-*.tar.gz -C aksusbd --strip-components=1 \
 && (cd aksusbd && ./dinst) \
 && /etc/init.d/aksusbd stop \
 && rm -rf aksusbd /var/hasplm/storage/ \
 && chmod a+rwX -R /var/hasplm/ /etc/hasplm/

COPY entrypoint.sh /app/
RUN chmod a+x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

Download

For Java application
FROM azul/zulu-openjdk:11

# IDLive Face SDK
ENV IDLIVEFACE_HOME=/app/idliveface

COPY idliveface/data ${IDLIVEFACE_HOME}/data/
COPY idliveface/libs ${IDLIVEFACE_HOME}/libs/
COPY idliveface/license ${IDLIVEFACE_HOME}/license/

# The application
ENV LD_LIBRARY_PATH=${IDLIVEFACE_HOME}/libs
ENV CLASSPATH=${IDLIVEFACE_HOME}/libs/java/*

COPY app.jar /app/
CMD ["java", "-jar", "/app/app.jar"]

# The license
RUN mkdir aksusbd \
 && tar zxf ${FACESDK_HOME}/license/rte/aksusbd-*.tar.gz -C aksusbd --strip-components=1 \
 && (cd aksusbd && ./dinst) \
 && /etc/init.d/aksusbd stop \
 && rm -rf aksusbd /var/hasplm/storage/ \
 && chmod a+rwX -R /var/hasplm/ /etc/hasplm/

COPY entrypoint.sh /app/
RUN chmod a+x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

Download

entrypoint.sh
#!/bin/sh
set -e

hasplmd_x86_64 -s && sleep 3
(cd "${IDLIVEFACE_HOME}/license" && ./install_license_linux rte/*.v2c)

exec "$@"

Download

To build the image run:

docker build -t idliveface-docker-example .

Run container

Use this command:

docker run --rm -it idliveface-docker-example

SYS_PTRACE capability

If you use Linux kernel older than 4.8 or your Docker’s version is older than 19.03 you need to additionally enable ptrace capability when starting the container:

docker run --cap-add=SYS_PTRACE ...

Otherwise the container may fail to start. This requirement was removed in the version 1.31.