You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2021/06/19 10:07:56 UTC

Doc of environment variables to modify docker images?

I'm in the process of moving my karaf based docker images from karaf
4.2.8 to karaf 4.3.2.

I'm trying to find the enviroment variables that will let me add maven
repositories, feature repositories and boot features, without copying
the files from the distro and modifying them.

But I haven't been able to google up these variables.

Is there a list of these variables somewhere?

(I thought they might be implemented by using ${env:xxx} in the .cfg
files, but there aren't any usage of "env:" in the etc directory of
karaf 4.3.2)

Thanks!


- Steinar


Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> Note: I had to use the karaf 4.3.0 image as the base for the docker
> image build, because the karaf 4.3.2 image doesn't work for me at all
> (see messages earlier in the thread).

> But the karaf 4.3.2 image obviously works for you?

> Could something have gone wrong in my pull from dockerhub?

> Is it possible to flush what I've pulled and try pulling again?

> (I'll google it...)

I've deleted all of my docker images and tried pulling a fresh
apache/karaf:4.3.2 from dockerhub, but starting 4.3.2 still fails for
me:
 https://gist.github.com/steinarb/6dd0db7a3d2f7dc952bcac56a668b342

Note: from the pull, it seems that "docker rmi" of images doesn't delete
everything...? 


Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

> Do you mean you have a race condition ?

No, I mean that the image created with this Dockerfile
 https://gist.github.com/steinarb/e2f4be17084cd622606547575f30df15
does not work as expected.

It doesn't do what it is supposed to do (log some key values of a
sonarqube run, to a database table, when run as a sonarquble webhook).

And "docker logs" doesn't mention the features I try adding to the boot
features set, at all.

Note: I had to use the karaf 4.3.0 image as the base for the docker
image build, because the karaf 4.3.2 image doesn't work for me at all
(see messages earlier in the thread).

But the karaf 4.3.2 image obviously works for you?

Could something have gone wrong in my pull from dockerhub?

Is it possible to flush what I've pulled and try pulling again?

(I'll google it...)

Note2: The feature I'm trying to load was built against the 4.3.2 BoM,
ie. newer than the 4.3.0 runtime.  Could this be the reason the features
don't appear? (no error messages, though...)


Re: Doc of environment variables to modify docker images?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Do you mean you have a race condition ?

Regards
JB

> Le 20 juin 2021 à 18:11, Jean-Baptiste Onofre <jb...@nanthrax.net> a écrit :
> 
> Just tested with Karaf 4.3.2:
> 
> $ export ORG_APACHE_KARAF_FEATURES_FEATURESREPOSITORIES="foo,mvn:no.priv.bang.sonar.sonar-collector/sonar-collector-webhook/LATEST/xml/features"
> $ bin/karaf
> karaf@root()> config:list "(service.pid=org.apache.karaf.features)"
> ----------------------------------------------------------------
> Pid:            org.apache.karaf.features
> BundleLocation: ?
> Properties:
>   featuresBoot = instance/4.3.2, package/4.3.2, log/4.3.2, ssh/4.3.2, framework/4.3.2, system/4.3.2, eventadmin/4.3.2, feature/4.3.2, shell/4.3.2, management/4.3.2, service/4.3.2, jaas/4.3.2, deployer/4.3.2, diagnostic/4.3.2, wrap/2.6.7, bundle/4.3.2, config/4.3.2, kar/4.3.2
>   featuresBootAsynchronous = false
>   featuresRepositories = foo,mvn:no.priv.bang.sonar.sonar-collector/sonar-collector-webhook/LATEST/xml/features
>   felix.fileinstall.filename = file:/Users/jbonofre/Downloads/apache-karaf-4.3.2/etc/org.apache.karaf.features.cfg
>   service.pid = org.apache.karaf.features
> 
> So, you can see the featuresRepositories contains the env variable value.
> 
> Regards
> JB
> 
>> Le 20 juin 2021 à 18:02, Steinar Bang <sb...@dod.no> a écrit :
>> 
>>>>>>> Steinar Bang <sb...@dod.no>:
>> 
>>> The apache/karaf:4.3.0 and apache/karaf:4.3.1 images both start fine in
>>> docker on my dev machine.
>> 
>>> I will try to build my image on top of 4.3.0 (I can't remember offhand
>>> why I couldn't run on 4.3.1...?).  
>> 
>>> Possible complication here is that I have bumbed the karaf BoM to 4.3.2,
>>> so I have built against something that is newer than the runtime...?
>> 
>> This is with an image based on top of apache/karaf:4.3.0
>> 
>> From the output of "docker logs"
>> https://gist.github.com/steinarb/d38767d99831e2816bc9d0a27d5a70ff
>> it looks like the feature repository and boot features I tried to add in
>> the Dockerfile weren't added:
>> https://gist.github.com/steinarb/65225c3a491c0b08a4386778f4c84100
>> 
>> Are my environment variables and their content incorrect?
>> 
> 


Re: Doc of environment variables to modify docker images?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Just tested with Karaf 4.3.2:

$ export ORG_APACHE_KARAF_FEATURES_FEATURESREPOSITORIES="foo,mvn:no.priv.bang.sonar.sonar-collector/sonar-collector-webhook/LATEST/xml/features"
$ bin/karaf
karaf@root()> config:list "(service.pid=org.apache.karaf.features)"
----------------------------------------------------------------
Pid:            org.apache.karaf.features
BundleLocation: ?
Properties:
   featuresBoot = instance/4.3.2, package/4.3.2, log/4.3.2, ssh/4.3.2, framework/4.3.2, system/4.3.2, eventadmin/4.3.2, feature/4.3.2, shell/4.3.2, management/4.3.2, service/4.3.2, jaas/4.3.2, deployer/4.3.2, diagnostic/4.3.2, wrap/2.6.7, bundle/4.3.2, config/4.3.2, kar/4.3.2
   featuresBootAsynchronous = false
   featuresRepositories = foo,mvn:no.priv.bang.sonar.sonar-collector/sonar-collector-webhook/LATEST/xml/features
   felix.fileinstall.filename = file:/Users/jbonofre/Downloads/apache-karaf-4.3.2/etc/org.apache.karaf.features.cfg
   service.pid = org.apache.karaf.features

So, you can see the featuresRepositories contains the env variable value.

Regards
JB

> Le 20 juin 2021 à 18:02, Steinar Bang <sb...@dod.no> a écrit :
> 
>>>>>> Steinar Bang <sb...@dod.no>:
> 
>> The apache/karaf:4.3.0 and apache/karaf:4.3.1 images both start fine in
>> docker on my dev machine.
> 
>> I will try to build my image on top of 4.3.0 (I can't remember offhand
>> why I couldn't run on 4.3.1...?).  
> 
>> Possible complication here is that I have bumbed the karaf BoM to 4.3.2,
>> so I have built against something that is newer than the runtime...?
> 
> This is with an image based on top of apache/karaf:4.3.0
> 
> From the output of "docker logs"
> https://gist.github.com/steinarb/d38767d99831e2816bc9d0a27d5a70ff
> it looks like the feature repository and boot features I tried to add in
> the Dockerfile weren't added:
> https://gist.github.com/steinarb/65225c3a491c0b08a4386778f4c84100
> 
> Are my environment variables and their content incorrect?
> 


Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> The apache/karaf:4.3.0 and apache/karaf:4.3.1 images both start fine in
> docker on my dev machine.

> I will try to build my image on top of 4.3.0 (I can't remember offhand
> why I couldn't run on 4.3.1...?).  

> Possible complication here is that I have bumbed the karaf BoM to 4.3.2,
> so I have built against something that is newer than the runtime...?

This is with an image based on top of apache/karaf:4.3.0

From the output of "docker logs"
 https://gist.github.com/steinarb/d38767d99831e2816bc9d0a27d5a70ff
it looks like the feature repository and boot features I tried to add in
the Dockerfile weren't added:
 https://gist.github.com/steinarb/65225c3a491c0b08a4386778f4c84100

Are my environment variables and their content incorrect?


Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> More debugging.  The apache/karaf:4.3.2 image fails to start on my
> developer machine:
[snip!]
> The apache/karaf:4.2.8 image (which was the last previous docker image
> I've used), starts fine.

> The host, ie. my dev machine, is an amd64, debian 10.10 "buster" system
> with docker.io 18.09.1+dfsg1-7.1+deb10u3

The apache/karaf:4.3.0 and apache/karaf:4.3.1 images both start fine in
docker on my dev machine.

I will try to build my image on top of 4.3.0 (I can't remember offhand
why I couldn't run on 4.3.1...?).  

Possible complication here is that I have bumbed the karaf BoM to 4.3.2,
so I have built against something that is newer than the runtime...?



Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
More debugging.  The apache/karaf:4.3.2 image fails to start on my
developer machine:
 sb@lorenzo:~/workspaces/ws02/sonar-collector/docker$ docker image pull apache/karaf:4.3.2
 4.3.2: Pulling from apache/karaf
 Digest: sha256:b5dd90b954029295e7fea62e56e8b767e02bc2ab274e3d0036fef7f2da29f682
 Status: Image is up to date for apache/karaf:4.3.2
 sb@lorenzo:~/workspaces/ws02/sonar-collector/docker$ docker run -d apache/karaf:4.3.2
 1dbbcdcd6bc3f77ac9a312d041fe9a8e1cbe10d90d9a9d0870c382e8702de571
 docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"karaf\": executable file not found in $PATH": unknown.
 sb@lorenzo:~/workspaces/ws02/sonar-collector/docker$

The apache/karaf:4.2.8 image (which was the last previous docker image
I've used), starts fine.

The host, ie. my dev machine, is an amd64, debian 10.10 "buster" system
with docker.io 18.09.1+dfsg1-7.1+deb10u3


Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> Ah, I think I understand now: there is a convention for naming
> environment variables, so that they can replace any config value?

> I.e. take the config value <someConfigValue>, prefix with
> ORG_APACHE_KARAF_FEATURES_ and uppercase it, ending up with
> ORG_APACHE_KARAF_FEATURES_SOMECONFIGVALUE?

> I will try!

I'm now trying with the following Dockerfile (the sonar-collector is on
maven central):
 https://gist.github.com/steinarb/65225c3a491c0b08a4386778f4c84100

But now I've run into a different problem: I can no longer copy .cfg
files into the etc directory of the karaf inside the image:
 https://gist.github.com/steinarb/71b6135e20dcad10962f4a1702d42663

I tried building an image on top of the karaf 4.2.8 docker image, and
copying .cfg files into the karaf etc/ worked fine there.

Is there a way of accomplishing this with the karaf 4.3.x docker image?

The .cfg file that fails in the copy, is a pax JDBC config file.


Re: Doc of environment variables to modify docker images?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

> Hi Steinar,
> With Karaf 4.3.x, you can now use "implicit" env variable.

> It’s documented here:

> http://karaf.apache.org/manual/latest/#_environment_variables_system_properties <http://karaf.apache.org/manual/latest/#_environment_variables_system_properties>

Hm... I read that part yesterday, but didn't understand it...?

> It means you can set features repositories with:

> export ORG_APACHE_KARAF_FEATURES_FEATURESREPOSITORIES='${featuresRepositories},mvn:org.apache.karaf.decanter/apache-karaf-decanter/2.5.0/xml/features'

Ah, I think I understand now: there is a convention for naming
environment variables, so that they can replace any config value?

I.e. take the config value <someConfigValue>, prefix with
ORG_APACHE_KARAF_FEATURES_ and uppercase it, ending up with
ORG_APACHE_KARAF_FEATURES_SOMECONFIGVALUE?

I will try!

Thanks!


Re: Doc of environment variables to modify docker images?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi Steinar,

With Karaf 4.3.x, you can now use "implicit" env variable.

It’s documented here:

http://karaf.apache.org/manual/latest/#_environment_variables_system_properties <http://karaf.apache.org/manual/latest/#_environment_variables_system_properties>

It means you can set features repositories with:

export ORG_APACHE_KARAF_FEATURES_FEATURESREPOSITORIES='${featuresRepositories},mvn:org.apache.karaf.decanter/apache-karaf-decanter/2.5.0/xml/features'

For instance

Regards
JB

> Le 19 juin 2021 à 12:07, Steinar Bang <sb...@dod.no> a écrit :
> 
> I'm in the process of moving my karaf based docker images from karaf
> 4.2.8 to karaf 4.3.2.
> 
> I'm trying to find the enviroment variables that will let me add maven
> repositories, feature repositories and boot features, without copying
> the files from the distro and modifying them.
> 
> But I haven't been able to google up these variables.
> 
> Is there a list of these variables somewhere?
> 
> (I thought they might be implemented by using ${env:xxx} in the .cfg
> files, but there aren't any usage of "env:" in the etc directory of
> karaf 4.3.2)
> 
> Thanks!
> 
> 
> - Steinar
>