You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Gerald Kallas (Jira)" <ji...@apache.org> on 2022/08/16 11:29:00 UTC
[jira] [Comment Edited] (KARAF-7448) Karaf file monitoring doesn't seem to work inside a docker container
[ https://issues.apache.org/jira/browse/KARAF-7448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17580264#comment-17580264 ]
Gerald Kallas edited comment on KARAF-7448 at 8/16/22 11:28 AM:
----------------------------------------------------------------
[~jbonofre] I tried te same steps as you have done ..
*Installation*
{code:java}
cd /opt
tar -xvf apache-karaf-4.4.1.tar.gz
ln -s /opt/apache-karaf-4.4.1 /opt/apache-karaf
cd /opt/apache-karaf/bin
./karaf
feature:repo-add camel 3.18.1
feature:install camel-blueprint{code}
*Validation of the deployment*
{code:java}
vi sample.xml
{code}
sample.xml looks like
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
">
<camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route>
<from uri="timer:fetch?period=3600s&delay=5s" />
<log message="Hello Camel!" />
</route>
</camelContext>
</blueprint> {code}
Log shows
{code:java}
2022-08-16T11:16:54,993 | INFO | FelixStartLevel | BlueprintContainerImpl | 54 - org.apache.aries.blueprint.core - 1.10.3 | Blueprint bundle sample.xml/0.0.0 has been started
2022-08-16T11:16:54,994 | INFO | Blueprint Event Dispatcher: 1 | BlueprintCamelContext | 104 - org.apache.camel.karaf.camel-blueprint - 3.18.1 | Attempting to start CamelContext: camel-1
2022-08-16T11:16:55,196 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Apache Camel 3.18.1 (camel-1) is starting
2022-08-16T11:16:55,402 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Routes startup (started:1)
2022-08-16T11:16:55,402 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Started route1 (timer://fetch)
2022-08-16T11:16:55,403 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Apache Camel 3.18.1 (camel-1) started in 439ms (build:32ms init:201ms start:206ms)
2022-08-16T11:17:00,406 | INFO | Camel (camel-1) thread #1 - timer://fetch | route1 | 72 - org.apache.camel.camel-core-reifier - 3.18.1 | Hello Camel! {code}
Stop Karaf
*Docker image creation*
{code:java}
tar cvzf apache-karaf-4.4.1-camel-3.18.1.tgz apache-karaf-4.4.1
./build.sh --from-local-dist --archive apache-karaf-4.4.1-camel-3.18.1.tgz{code}
*Docker container run*
{code:java}
docker run --name test karaf {code}
Change of the (changed) sample.xml inside the docker container
{code:java}
docker cp /opt/apache-karaf/deploy/sample.xml test:/opt/apache-karaf/deploy/ {code}
Nothing happens.
was (Author: catshout):
[~jbonofre] I tried te same steps as you have done ..
*Installation*
{code:java}
cd /opt
tar -xvf apache-karaf-4.4.1.tar.gz
ln -s /opt/apache-karaf-4.4.1 /opt/apache-karaf
cd /opt/apache-karaf/bin
./karaf
feature:repo-add camel 3.18.1
feature:install camel-blueprint{code}
*Validation of the deployment*
{code:java}
vi sample.xml
{code}
sample.xml looks like
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
">
<camelContext xmlns="http://camel.apache.org/schema/blueprint"> <route>
<from uri="timer:fetch?period=3600s&delay=5s" />
<log message="Hello Camel!" />
</route>
</camelContext>
</blueprint> {code}
Log shows
{code:java}
2022-08-16T11:16:54,993 | INFO | FelixStartLevel | BlueprintContainerImpl | 54 - org.apache.aries.blueprint.core - 1.10.3 | Blueprint bundle sample.xml/0.0.0 has been started
2022-08-16T11:16:54,994 | INFO | Blueprint Event Dispatcher: 1 | BlueprintCamelContext | 104 - org.apache.camel.karaf.camel-blueprint - 3.18.1 | Attempting to start CamelContext: camel-1
2022-08-16T11:16:55,196 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Apache Camel 3.18.1 (camel-1) is starting
2022-08-16T11:16:55,402 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Routes startup (started:1)
2022-08-16T11:16:55,402 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Started route1 (timer://fetch)
2022-08-16T11:16:55,403 | INFO | Blueprint Event Dispatcher: 1 | AbstractCamelContext | 61 - org.apache.camel.camel-base-engine - 3.18.1 | Apache Camel 3.18.1 (camel-1) started in 439ms (build:32ms init:201ms start:206ms)
2022-08-16T11:17:00,406 | INFO | Camel (camel-1) thread #1 - timer://fetch | route1 | 72 - org.apache.camel.camel-core-reifier - 3.18.1 | Hello Camel! {code}
Stop Karaf
*Docker image creation*
{code:java}
tar cvzf apache-karaf-4.4.1-camel-3.18.1.tgz apache-karaf-4.4.1
./build.sh --from-local-dist --archive apache-karaf-4.4.1-camel-3.18.1.tgz{code}
*Docker container run*
{code:java}
docker run --name test karaf {code}
Change of the (changed) sample.xml inside the docker container
{code:java}
docker cp /opt/apache-karaf/deploy/sample.xml test:/opt/apache-karaf/deploy/ {code}
Nothing happens.
> Karaf file monitoring doesn't seem to work inside a docker container
> --------------------------------------------------------------------
>
> Key: KARAF-7448
> URL: https://issues.apache.org/jira/browse/KARAF-7448
> Project: Karaf
> Issue Type: Bug
> Components: karaf
> Affects Versions: 4.4.0
> Reporter: Gerald Kallas
> Assignee: Jean-Baptiste Onofré
> Priority: Critical
>
> After the creation of a vanilla Karaf installation w/ some additional components I did wrap the installation into a docker image/container. When performing a hot deployment inside the created container the file monitoring doesn't seem to work as expected.
> I did perform similar tests with older versions (Karaf 4.2.9 and Camel 3.4.4), there the file monitoring works.
>
> *Steps to reproduce*
> _Base installation_
> {code:java}
> cd /opt/
> tar -xvf apache-karaf-4.4.1.tar.gz
> ln -s /opt/apache-karaf-4.4.1 /opt/apache-karaf
> cd /opt/apache-karaf/bin ./karaf{code}
> _Feature installation_
> {code:java}
> feature:repo-add hawtio 2.14.5
> feature:repo-add activemq 5.17.1
> feature:repo-add camel 3.14.3
> feature:install pax-web-jetty
> feature:install hawtio activemq-broker-noweb camel camel-jms jms camel-http camel-servlet camel-swagger-java camel-ftp camel-jackson camel-jsonpath camel-json-validator camel-zipfile camel-velocity camel-groovy camel-salesforce camel-kafka{code}
> _Testing the pre-installed Karaf_
> sample1.xml looks like
> {code:java}
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
> xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="
> http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
> <reference id="httpService" interface="org.osgi.service.http.HttpService" />
> <bean id="camelServlet1" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
> <bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
> init-method="register"
> destroy-method="unregister">
> <property name="servletName" value="servlet1" />
> <property name="alias" value="/test1" />
> <property name="httpService" ref="httpService" />
> <property name="servlet" ref="camelServlet1" />
> </bean>
> <camelContext id="sample1" xmlns="http://camel.apache.org/schema/blueprint">
> <route>
> <from uri="servlet://hello?servletName=servlet1" />
> <log message="Hello Camel 1!" />
> </route>
> </camelContext>
> </blueprint> {code}
> {code:java}
> cp sample1.xml /opt/apache-karaf/deploy/{code}
> The route will be deployed as expected and is running properly.
> _Packaging the archive_
> {code:java}
> tar cvzf apache-karaf-4.4.0-camel-3.14.3.tgz apache-karaf-4.4.0{code}
> _Creating and running the docker container_
> {code:java}
> docker-compose -f docker-compose_Linux.yml up --build -d{code}
> The following does have no effect
> {code:java}
> docker cp sample1.xml casisp:/opt/apache-karaf/deploy/{code}
>
> Dockerfile looks like
> {code:java}
> FROM openjdk:11-jre# Set karaf environment variables
> ENV KARAF_INSTALL_PATH /opt
> ENV KARAF_HOME $KARAF_INSTALL_PATH/apache-karaf
> ENV PATH $PATH:$KARAF_HOME/bin# Copy and untar the karaf distribution
> COPY *.tgz* /tmp/
> RUN cat /tmp/*.tgz* | tar xzf - --directory $KARAF_INSTALL_PATH && \
> rm /tmp/*.tgz*# Install build dependencies and karaf
> RUN set -x && \
> ln -s $KARAF_INSTALL_PATH/apache-karaf* $KARAF_HOME# Create casisp user
> RUN groupadd --gid 2000 casisp && \
> useradd --uid 2000 --create-home --home-dir /var/casisp --gid casisp casisp# Set user permissions
> RUN mkdir -p /var/casisp/files && \
> mkdir /opt/apache-karaf/templates && \
> chown -R casisp:casisp /var/casisp && \
> chown -R casisp:casisp /opt/apache-karaf*EXPOSE 8101 1099 44444 8181 8443
> USER casisp
> CMD ["karaf", "run"] {code}
> docker-compose_Linux.yml looks like
> {code:java}
> version: '3'
> services:
> karaf:
> container_name: casisp
> user: "2000"
> build: .
> restart: unless-stopped
> network_mode: bridge
> ports:
> - "8101:8101"
> - "1099:1099"
> - "44444:44444"
> - "8181:8181"
> - "8443:8443"
> - "8182:8182"
> - "8444:8444"
> command: karaf
> stdin_open: true
> tty: true {code}
> The docker directory looks like
> {code:java}
> ll
> total 156128
> -rw-rw-r-- 1 casisp casisp 159859132 Jun 6 15:37 apache-karaf-4.4.1-camel-3.14.3.tgz
> -rw-rw-r-- 1 casisp casisp 349 Jun 6 15:40 docker-compose_Linux.yml
> -rw-rw-r-- 1 casisp casisp 819 Jun 5 13:02 Dockerfile {code}
> *OS and docker release information*
> {code:java}
> cat /etc/os-release
> NAME="Amazon Linux"
> VERSION="2"
> ID="amzn"
> ID_LIKE="centos rhel fedora"
> VERSION_ID="2"
> PRETTY_NAME="Amazon Linux 2"
> ANSI_COLOR="0;33"
> CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
> HOME_URL="https://amazonlinux.com/"
> docker version
> Client:
> Version: 20.10.13
> API version: 1.41
> Go version: go1.16.15
> Git commit: a224086
> Built: Thu Mar 31 19:20:32 2022
> OS/Arch: linux/amd64
> Context: default
> Experimental: trueServer:
> Engine:
> Version: 20.10.13
> API version: 1.41 (minimum version 1.12)
> Go version: go1.16.15
> Git commit: 906f57f
> Built: Thu Mar 31 19:21:13 2022
> OS/Arch: linux/amd64
> Experimental: false
> containerd:
> Version: 1.4.13
> GitCommit: 9cc61520f4cd876b86e77edfeb88fbcd536d1f9d
> runc:
> Version: 1.0.3
> GitCommit: f46b6ba2c9314cfc8caae24a32ec5fe9ef1059fe
> docker-init:
> Version: 0.19.0
> GitCommit: de40ad0
> docker-compose version
> docker-compose version 1.22.0, build f46880fe
> docker-py version: 3.4.1
> CPython version: 3.6.6
> OpenSSL version: OpenSSL 1.1.0f 25 May 2017{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)