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/06/06 16:07:00 UTC

[jira] [Updated] (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:all-tabpanel ]

Gerald Kallas updated KARAF-7448:
---------------------------------
    Description: 
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 Camal 3.4.4), there the file monitoring works.

 

*Steps to reproduce*

_Base installation_
{code:java}
cd /opt/
tar -xvf apache-karaf-4.4.0.tar.gz
ln -s /opt/apache-karaf-4.4.0 /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}
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.0-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}

  was:
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 Camal 3.4.4), there the file monitoring works.


> 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
>         Environment: *Steps to reproduce*
> _Base installation_
>  
> {code:java}
> {code}
> _cd /opt/_
> _tar -xvf apache-karaf-4.4.0.tar.gz_
> _ln -s /opt/apache-karaf-4.4.0 /opt/apache-karaf_
> _cd /opt/apache-karaf/bin
> ./karaf_
> _Feature installation_
>  
>  
> {code:java}
> {code}
> _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_ 
> _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}
> {code}
> _cp sample1.xml /opt/apache-karaf/deploy/_ 
> The route will be deployed as expected and is running properly.
>  
> _Packaging the archive_
>  
> {code:java}
> {code}
> _tar cvzf apache-karaf-4.4.0-camel-3.14.3.tgz apache-karaf-4.4.0_ 
> _Creating and running the docker container_
>  
>  
> {code:java}
> {code}
> _docker-compose -f docker-compose_Linux.yml up --build -d_ 
> 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.0-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}
>            Reporter: Gerald Kallas
>            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 Camal 3.4.4), there the file monitoring works.
>  
> *Steps to reproduce*
> _Base installation_
> {code:java}
> cd /opt/
> tar -xvf apache-karaf-4.4.0.tar.gz
> ln -s /opt/apache-karaf-4.4.0 /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}
> 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.0-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.7#820007)