Skip to content
Michalis Kamburelis edited this page Feb 16, 2019 · 2 revisions

Using Castle Game Engine inside a Docker image

We have a Docker image that contains Castle Game Engine along with various tools preconfigured. The image is available on Docker hub, the image is called "kambi/castle-engine-cloud-builds-tools".

Using the Docker image gives you a stable environment where we have:

  • FPC (stable and unstable versions) with cross-compilers for various platforms
  • Android SDK and NDK
  • Texture compression tools useful with CGE
  • Castle Game Engine (stable and unstable versions, depending on the Docker image tag: cge-stable, cge-unstable, cge-none).

This Docker image is used by our Cloud Builds (Jenkins) . It can also be used on your local computer. Instead of downloading FPC, CGE, Android SDK and NDK etc., you only have to get the Docker image.

Getting the Docker, basic Docker concepts and links

Follow the to install Docker. You will most likely want to follow the official docs about Installing Docker Community Edition.

You should read the Docker documentation and Reference to understand some Docker terminology.

Here's a short version:

  • "Docker image" is like a template for a virtual machine.

  • "Docker container" is like an actual virtual machine with installed OS (Linux).

  • A stopped container is like a stopped operating system, you can run it again (and have the same files).

There are two ways to use Docker container:

  • You can easily create and destroy temporary Docker containers, even to just execute a single command.

  • You can also just create and use one Docker container for a long time.

Using the Docker image

Commands below may serve as an example how to use our Docker image to easily create a Docker container my-cge-container, and use it quite like a virtual machine.

Treat these commands as an example, please. There are various ways of doing this. These commands are written with a Linux user in mind --- on Windows you will have to adjust them.

First run a container from a console like this:

docker run --name my-cge-container --volume="${HOME}":/home/sharedhome/ -it kambi/castle-engine-cloud-builds-tools:cge-unstable bash

You can play around in the resulting shell, end by Ctrl + D (or exit and Enter).

Next time, enter this container like this:

docker start my-cge-container # make container running
docker attach my-cge-container # attach to the new "bash" process inside

To remove the container from your system:

docker rm my-cge-container

Inside the container, you have a regular Linux command-line.

  • Try commands like fpc -l or castle-engine --version to make sure you have FPC and CGE inside the container.

  • Try ls /home/sharedhome/ to make sure you see your shared directory, if you followed the above example usage of --volume.

  • You can install whatever you need (apt-get install ... works), and just use it as a regular virtual machine.

  • Example above shows using --volume option for docker run to share your $HOME directory. You can also copy files between host/container using docker cp ( ).

Using the Docker image to compile CGE applications

Inside the Docker container, just use the installed castle-engine build tool to compile your projects, like this:

cd /home/sharedhome/my-game/
castle-engine compile
castle-engine package

Your project directory needs to have a CastleEngineManifest.xml file inside. Or you can compile any Pascal source with castle-engine simple-compile someunit.pas. There are many other commands available, see the build tool documentation.

You can easily create an Android application (APK file) with:

castle-engine package --os=android --cpu=arm

This way you don't need to install all the things mentioned at -- they are already available inside the Docker container. You get an APK, which you can copy to your Android device (phone, tablet) in any way, and then install and run it -- like any other application in APK form.

If you want to generate compressed textures, you can run in Docker container

castle-engine auto-generate-textures

The advantage is, again, that you don't need to install all the tools mentioned on the generating compressed textures docs. These tools are ready inside the Docker container.

You can also use command-line fpc or lazbuild to build Pascal applications. By default we use the latest stable FPC/Lazarus, but this can be switched by executing command like source /usr/local/fpclazarus/bin/ trunk. This will make you use FPC 3.3.1 within this shell.


Although Lazarus is installed inside the container, but it's primary use is to run lazbuild to compile Lazarus packages. As the container doesn't have visual libraries (X) installed, or connected to your host display, you cannot readily use GUI Lazarus for development. It is possible to execute GUI application inside Docker, but it may be easier to just install Lazarus in a normal way, on your host system.

Using Android SDK to install and run APK will not work, as inside the Docker container it doesn't see your USB devices. So adb devices, adb logcat, castle-engine install --os=android --cpu=arm, castle-engine run --os=android --cpu=arm will not work within the container. For this, you need to install Android SDK/NDK on your regular host system.

Castle Game Engine:

Wiki Contents:

Build Tool:

Mobile devices:



Clone this wiki locally
You can’t perform that action at this time.