I am trying to create a Dockerfile that will automatically install apache karaf and configure it to work and its working fine.
I want to install list of features. I can do it with below
docker exec -it 7447419c89da /opt/karaf/bin/client
but I want to automate the process. What command can I run that will allow me to install the features?
You can use XML file (Feature Repository] and copy it into .../apache-karaf-4.1.5/deploy folder. Then it will be picked-up by Karaf during start-time and features described in the file will be installed automatically if they have attribute specified: install="auto"
.
Sample file:
<features
name="AET Features"
xmlns="http://karaf.apache.org/xmlns/features/v1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0">
<repository>mvn:org.apache.cxf.karaf/apache-cxf/3.2.0/xml/features</repository>
<feature name="fooo" version="1.0.0" description="Features that should be installed" install="auto">
<feature>cxf-core</feature>
<feature>webconsole</feature>
<bundle>mvn:org.apache.karaf.webconsole/org.apache.karaf.webconsole.features/4.1.2</bundle>
</feature>
</features>
This will install new feature called fooo which consist of cxf-core feature - just for purpose of this example (this one needs its own repository location), the webconsole feature that is available on Karaf and additional bundle that provides a view of features in the Web Console.
To summarise:
required-features.xml
with features descriptionYou can find examples of feature files in Karaf source, e.g.:
https://github.com/apache/karaf/blob/master/assemblies/features/spring/src/main/feature/feature.xml