How to 'dockerize' pdfToolbox
Important to note here is that:
- Licensing requires a callas License Server (running outside the Docker Container)
- A callas License Server itself cannot run in a Docker Container
- In general, only the 64bit callas binaries can run inside a Docker Container
- Docker Host: The Operating System that executes the docker program
- Docker Image: Some kind of Filesystem (comparable to a readonly ISO CDROM Image)
- Docker Container: A docker Image that is executed by the docker program
- callas OS binary: The OS specific callas software executable, e.g.
- pdfToolbox.exe (for Windows)
- Only the CLI edition is supported (not the GUI edition)
- Only supported on Microsoft Windows Docker Hosts
- Only supported for Microsoft Windows Docker Images
- In other Words: It is not possible to run native Microsoft Windows binaries inside a Linux Docker Host (or a MacOS Docker Host)
- pdfToolbox (for Linux)
- Supported on every Docker Host platform (Linux, Windows and MacOS)
- Needs a Linux glibc compatible Docker container. As a consequence Alpine Linux Containers are not supported (not based on glibc)
- Windows specific: only the Linux mode is supported (Hyper-V Isolation)
- pdfToolbox (for MacOS)
- Not possible (there are no MacOS Docker Images)
- pdfToolbox.exe (for Windows)
Preparing "enriched" Docker Images
A Docker image must contain the needed runtime dependencies for the callas application (aka Binary). This will be named an enriched Docker image.
It is recommended to use a Dockerfile to prepare such an enriched Docker image
Note: It is also recommended to use a dedicated build directory that contains the Dockerfile, e.g. a directory named docker_build
Note: Only the Docker base images used in the examples below are officially supported by callas software. In other words: you are free to use different base images. But (as there are thousands of different base images) only the base images mentioned here are officially supported by callas software.
As a base image, the official debian:latest image will be used. There are many external dependencies but these dependencies will be automatically fetched and installed
Create a text file named Dockerfile inside the docker_build directory
FROM debian:latest # add some additional repositories (and packages) RUN sed -i 's,main$,main contrib non-free,' /etc/apt/sources.list \ && apt update \ && apt install -y \ fontconfig \ libfreetype6 \ lsb-release \ vim-tiny \ perl-modules \ ttf-mscorefonts-installer \ && apt autoremove \ && apt autoclean \ && rm -r -f /var/lib/apt/lists \ && rm -r -f /usr/share/doc \ && rm -r -f /usr/share/man CMD ["/bin/bash"]
Now use the Docker build command to create the enriched image (named debian-enriched)
cd <directory containing Dockerfile> docker build -t debian-enriched .
docker images debian-enriched REPOSITORY TAG IMAGE ID CREATED SIZE debian-enriched latest 3d359679e001 20 minutes ago 218MB
As a base image the official servercore:ltsc2019 image will be used. External dependencies are only Microsoft Visual Studio Distributable (VC_redist.x64.exe). But it needs to be downloaded manually.
Download VC_redist.x64.exe into the docker_build directory (URL: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) and create a text file named Dockerfile inside the docker_build directory.
FROM mcr.microsoft.com/windows/servercore:ltsc2019 RUN MKDIR \tmp # VC_redist.x64.exe from https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads COPY VC_redist.x64.exe \tmp RUN start /w \tmp\VC_redist.x64.exe /install /quiet /norestart USER ContainerUser
Use the docker build command to create the enriched image (named servercore-enriched)
cd <directory containing Dockerfile and VC_redist.x64.exe> docker build -t servercore-enriched .
docker images servercore-enriched REPOSITORY TAG IMAGE ID CREATED SIZE servercore-enriched latest 1ad53e86e52f 16 minutes ago 3.86GB
Running a callas product in a Docker Container
Note: This requires an already running callas License Server (loaded with a cartridge that matches the product), e.g. running on 192.168.44.11
unpack the pdfToolbox Installer .tar.gz into a dedicated directory (e.g./opt/callas/callas_pdfToolboxCLI_x64_Linux_11-1-542)
cd /opt/callas/callas_pdfToolboxCLI_x64_Linux_11-1-542 docker run --rm -v $(pwd):/callas -t -i debian-enriched
Now we are inside a Linux Docker Container.
cd /callas ./pdfToolbox --pdfa 'doc/callas pdfToolbox CLI.pdf' --licenseserver=192.168.44.11
- Unpack the pdfToolbox CLI Installer (not the Desktop GUI Installer)
- Install the pdfToolbox CLI into a dedicated directory (not the default system directories), e.g use C:\docker\callas_pdfToolboxCLI11_x64_Win_11-1-542
cd C:\docker\callas_pdfToolboxCLI11_x64_Win_11-1-542 docker run --rm -ti --mount "type=bind,source=%cd%,target=c:/callas" servercore-enriched
Now we are inside a Windows Docker Container.
cd \callas pdfToolbox.exe --pdfa "doc\callas pdfToolbox CLI.pdf" --licenseserver=192.168.44.11