How to dockerize customized Apache Karaf server based application?

390 Views Asked by At

We used customized apache karaf server to deploy OSGI bundles. we have an installer that install customized apache karaf along with the OSGI bundles and whole run as a Linux service. The problem with installer is it takes dynamic parameters that are configured in properties files required for bundles. From docker point of view, we are running the installer in the container and manually updating the configuration files, So every time if i am a using same image to spawn new a container i need to manually update the configuration files.Is it right way?

1

There are 1 best solutions below

0
andov On

Let's start from here:

"we are running the installer in the container and manually updating the configuration files"

and to keep it simple, let's also assume that you have a standalone Docker daemon up and running (no Swarm or Kubernetes orchestrator).

Your problem is the following:

"So every time if i am a using same image to spawn new a container i need to manually update the configuration files"

To reduce any manual intervention you can use already written properties files. These files will be stored somewhere on the filesystem of your Docker host. You need also to know where on the virtual filesystem of the container the properties files are located.

At this point, using the Docker CLI, you can run the following command:

docker run ... -v /the-path/on/the-docker-host-filesystem/to-properties-directory:/file-location/inside-the-container/to-properties ... docker_img:img_version ...

Notice that:

  • in the previous command, I omitted any specific configuration for the container and I assumed that all the properties files are located inside the same directory;
  • this approach does not scale in production.

To get more information about how to use Docker volumes have a look at the following Docker documentation page here.

Within a Docker Swarm environment, you can use the config object. To understand better what configs are and how to use them, have a look here.