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 2020/04/06 09:04:54 UTC
Trying out the karaf docker image
I'm using https://labs.pay-with-docker.com which lets anyone with a
dockerhub user try out a docker container for 4 hours until it's teared
down.
I've done the following:
1. Opened https://labs.play-with-docker.com in a browser
2. Pulled down docker image 4.2.8:
docker pull apache/karaf:4.2.8
3. Did the command "docker images":
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
apache/karaf 4.2.8 e6e9f0f9c039 2 weeks ago 291MB
[node1] (local) root@192.168.0.48 ~
$
4. Tried the command "docker run apache/karaf" but got an error message
that docker was unable to find tag latest
5. Tried the command "docker run apache/karaf:4.28" which worked better
6. I didn't get the prompt back in the command shell
7. I tried opening port 8101 by clicking on the "Open port" button, but
that failed
8. I ssh'd in using the provided hostname and got a docker command
line:
ssh ip172-18-0-18-bq5dejroudsg00b7tegg@direct.labs.play-with-docker.com
9. I tried doing ssh into karaf but failed:
$ ssh -p 8101 karaf@localhost
ssh: connect to host localhost port 8101: Connection refused
[node1] (local) root@192.168.0.48 ~
$
Is there a way to get a karaf console?
(it doesn't have to be through ssh)
Or is the container karaf without a console?
Thanks!
- Steinar
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,
It’s configurable now (you have the option to use internal volume or not).
Regards
JB
> Le 8 avr. 2020 à 09:30, Gerald Kallas <ca...@mailbox.org> a écrit :
>
> Yep. AFAIK the docker:provision puts all karaf directories on the host VM. That's the reason why we're doing it manually. Am I right with this?
>
>> Jean-Baptiste Onofre <jb...@nanthrax.net> hat am 8. April 2020 07:23 geschrieben:
>>
>>
>> It’s more or less what docker:provision is doing ;)
>>
>> Regards
>> JB
>>
>>> Le 7 avr. 2020 à 17:52, Gerald Kallas <ca...@mailbox.org> a écrit :
>>>
>>> Hi, that's the way I did w/ Camel on Karaf
>>>
>>> 1. Start karaf
>>>
>>> cd /opt
>>> unzip /home/karaf/apache-karaf-4.2.7.zip
>>> ln -s /opt/apache-karaf* /opt/apache-karaf
>>> cd apache-karaf/bin
>>> ./karaf
>>>
>>> 2. Install the needed features (in a 2nd SSH session)
>>>
>>> cd /opt/apache-karaf/bin
>>> ./client < karaf.sh
>>>
>>> karaf.sh looks like
>>>
>>> feature:repo-add hawtio 2.9.1
>>> feature:repo-add activemq 5.15.11
>>> feature:repo-add camel 3.1.0
>>> feature:install webconsole hawtio activemq-broker-noweb camel camel-jms jms camel-http camel-jetty camel-swagger-java camel-ftp camel-jackson camel-jsonpath camel-zipfile camel-velocity camel-groovy
>>>
>>> 3. Package the archive file of the ready-to-run karaf
>>>
>>> ^D
>>> tar -czvf apache-karaf-4.2.7-camel-3.0.1.tgz apache-karaf-4.2.7
>>> cp apache-karaf apache-karaf-4.2.7-apache-camel-3.0.1.tgz /home/karaf
>>>
>>> 4. Build the docker container based on the created archive, the Dockerfile and docker-compose
>>>
>>> docker-compose up --build -d
>>>
>>> Dockerfile looks like
>>>
>>> FROM openjdk:8-jre
>>>
>>> # Set karaf environment variables
>>> ENV KARAF_INSTALL_PATH /opt
>>> ENV KARAF_HOME $KARAF_INSTALL_PATH/apache-karaf
>>> ENV PATH $PATH:$KARAF_HOME/bin
>>>
>>> # The karaf_dist can point to a directory or a tarball on the local system
>>> ARG karaf_dist=apache-karaf-4.2.7-camel-3.0.1.tgz
>>>
>>> # Install build dependencies and karaf
>>> ADD $karaf_dist $KARAF_INSTALL_PATH
>>> RUN set -x && \
>>> ln -s $KARAF_INSTALL_PATH/apache-karaf* $KARAF_HOME
>>>
>>> # Create karaf user
>>> RUN groupadd --gid 2000 karaf && \
>>> useradd --uid 2000 --create-home --home-dir /var/karaf --gid karaf karaf
>>>
>>> # Set user permissions
>>> RUN mkdir -p /var/karaf/files && \
>>> mkdir /opt/apache-karaf/templates && \
>>> chown -R karaf:karaf /var/karaf && \
>>> chown -R karaf:karaf /opt/apache-karaf*
>>>
>>> EXPOSE 8101 1099 44444 8181 8443
>>> USER karaf
>>> CMD ["karaf", "run"]
>>>
>>> docker-compose looks like
>>>
>>> services:
>>> karaf:
>>> container_name: karaf
>>> user: "2000"
>>> build: .
>>> restart: unless-stopped
>>> network_mode: bridge
>>> ports:
>>> - "8101:8101"
>>> - "1099:1099"
>>> - "44444:44444"
>>> - "8181:8181"
>>> - "8443:8443"
>>> - "8182:8182"
>>> - "8444:8444"
>>> volumes:
>>> - /var/karaf/etc:/opt/apache-karaf/etc
>>> - /var/karaf/deploy:/opt/apache-karaf/deploy
>>> - /var/karaf/templates:/opt/apache-karaf/templates
>>> - /var/karaf/files:/var/casisp/files
>>> command: karaf
>>> stdin_open: true
>>> tty: true
>>>
>>> So far I'm exposing the 4 directories
>>>
>>> karaf/etc
>>> karaf/deploy
>>> karaf/templates (for Velocity templates we're using)
>>> karaf/files (for file component consumer and producer)
>>>
>>> For me it works well. I've to do a little bit of improvement
>>>
>>> 1. The .m2 Maven directory isn't included yet within the container, so far ist shows some warnings while starting offline
>>> 2. Active MQ shows in offline start mode an error because one file is missing
>>>
>>> Both I'm going to solve within the next couple of days.
>>>
>>> Best
>>> - Gerald
>>>
>>>> Steinar Bang <sb...@dod.no> hat am 7. April 2020 14:23 geschrieben:
>>>>
>>>>
>>>>>>>>> Steinar Bang <sb...@dod.no>:
>>>>
>>>>> Is there a way to flush what docker:provision has made?
>>>>
>>>> Yes. Use the "docker" command on the host (docker installed with
>>>> "apt install docker.io" on a debian stable system):
>>>> docker rm -vf $(docker ps -a -q)
>>>> docker rmi -f $(docker images -a -q)
>>>>
>>>> Source: https://stackoverflow.com/a/44785784
>>>>
>>>>> And is there a way to extract the image docker:provision has made and
>>>>> make it into something that can be pushed to dockerhub?
>>>>
>>>> Yes. I did the following:
>>>> 1. Created the repo ukelonn-demo on docker hub: https://hub.docker.com/repository/docker/steinarb/ukelonn-demo/tags?page=1
>>>>
>>>> 2. Ran the commands above to clear out the local docker instance of all images
>>>>
>>>> 3. Logged the docker instance on my local machine (the one running both
>>>> karaf and dockerd):
>>>> docker login --username=yourhubusername --email=youremail@company.com
>>>>
>>>> 4. In karaf, deleted the data directory to start fresh, started karaf
>>>> and populated karaf with features, and provisioned the running karaf
>>>> (note: this requires my own maven repo, and karaf already had that):
>>>> feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
>>>> feature:install ukelonn-with-derby
>>>> feature:install docker
>>>> docker:provision ukelonn-demo
>>>>
>>>> 5. Ran "docker images" to find the id of the provisioned karaf instance
>>>> (at this point it was the only image in the local docker)
>>>> sb@lorenzo:~$ docker images
>>>> REPOSITORY TAG IMAGE ID CREATED
>>>> SIZE
>>>> java 8-jre-alpine fdc893b19a14 3 years
>>>> ago 108MB
>>>> sb@lorenzo:~$
>>>>
>>>> 6. Created a tag using my dockerhub username, the name of the repo I'd
>>>> created and the date and time of day:
>>>> sb@lorenzo:~$ docker tag fdc893b19a14 steinarb/ukelonn-demo:202004071205
>>>> sb@lorenzo:~$
>>>>
>>>> 7. Pushed the tag to docker hub:
>>>> sb@lorenzo:~$ docker push steinarb/ukelonn-demo:202004071205
>>>> The push refers to repository [docker.io/steinarb/ukelonn-demo]
>>>> 20dd87a4c2ab: Mounted from library/java
>>>> 78075328e0da: Mounted from library/java
>>>> 9f8566ee5135: Mounted from library/java
>>>> 202004071205: digest:
>>>> sha256:6a8cbe4335d1a5711a52912b684e30d6dbfab681a6733440ff7241b05a5deefd
>>>> size: 947
>>>> sb@lorenzo:~$
>>>>
>>>> 8. Opened https://labs.play-with-docker.com in a web browser and
>>>> clicked on "Start"
>>>>
>>>> 9. In the command shell, pulled the image from docker hub:
>>>> docker pull steinarb/ukelonn-demo:202004071205
>>>>
>>>> 10. Tried running the image, but that failed with "no command specified":
>>>> [node1] (local) root@192.168.0.18 ~
>>>> $ docker run -p 8101:8101 -p 8181:8181
>>>> steinarb/ukelonn-demo:202004071205
>>>> docker: Error response from daemon: No command specified.
>>>> See 'docker run --help'.
>>>> [node1] (local) root@192.168.0.18 ~
>>>> $
>>>>
>>>> So I'm not all the way yet, but I'm getting closer.
>>>>
>>>> Source for the docker hub related docker commands: https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html
>>>>
>>>>> Or do I need to look at more traditional docker image building, using a
>>>>> Dockerfile?
>>>>
>>>> Possibly...? At least if I want to automate the build of docker images.
>>>>
>>>> But for now it's interesting to see how far I can get just by playing
>>>> with some commands.
Re: Trying out the karaf docker image
Posted by Francois Papon <fr...@openobject.fr>.
Hi Steinar,
I wrote a blog post on how to create a Karaf custom distribution and create a Docker image with JIB:
https://fpapon.github.io/2020/03/21/karaf-custom-distribution/
May be you can find some tips.
regards,
François
fpapon@apache.org
Le 08/04/2020 à 12:22, Steinar Bang a écrit :
>>>>>> Steinar Bang <sb...@dod.no>:
>>> Yep. AFAIK the docker:provision puts all karaf directories on the host VM. That's the reason why we're doing it manually. Am I right with this?
>> I googled the error message I got: docker: Error response from daemon: No command specified.
>> I found this:
>> https://serverfault.com/questions/757210/no-command-specified-from-re-imported-docker-image-container
>> Is the cause of my error message that docker:provision created an image
>> without e.g. the etc directory and expected the docker container to
>> provide those directories?
> At a little further googling I tried adding a command to the run, to
> fire up karaf, but both my guesses ("bin/karaf" and "karaf"), failed:
>
> [node1] (local) root@192.168.0.13 ~
> $ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205 bin/karaf
> docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"bin/karaf\": stat bin/karaf: no such file or directory": unknown.
> ERRO[0001] error waiting for container: context canceled
> [node1] (local) root@192.168.0.13 ~
> $ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205 karaf
> docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"karaf\": executable file not found in $PATH": unknown.
> ERRO[0001] error waiting for container: context canceled
> [node1] (local) root@192.168.0.13 ~
> $
>
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
You can take a look on the script provided with Karaf:
https://github.com/apache/karaf/tree/master/assemblies/docker <https://github.com/apache/karaf/tree/master/assemblies/docker>
Regards
JB
> Le 8 avr. 2020 à 12:22, Steinar Bang <sb...@dod.no> a écrit :
>
>>>>>> Steinar Bang <sb...@dod.no>:
>
>>> Yep. AFAIK the docker:provision puts all karaf directories on the host VM. That's the reason why we're doing it manually. Am I right with this?
>
>> I googled the error message I got: docker: Error response from daemon: No command specified.
>
>> I found this:
>> https://serverfault.com/questions/757210/no-command-specified-from-re-imported-docker-image-container
>
>> Is the cause of my error message that docker:provision created an image
>> without e.g. the etc directory and expected the docker container to
>> provide those directories?
>
> At a little further googling I tried adding a command to the run, to
> fire up karaf, but both my guesses ("bin/karaf" and "karaf"), failed:
>
> [node1] (local) root@192.168.0.13 ~
> $ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205 bin/karaf
> docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"bin/karaf\": stat bin/karaf: no such file or directory": unknown.
> ERRO[0001] error waiting for container: context canceled
> [node1] (local) root@192.168.0.13 ~
> $ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205 karaf
> docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"karaf\": executable file not found in $PATH": unknown.
> ERRO[0001] error waiting for container: context canceled
> [node1] (local) root@192.168.0.13 ~
> $
>
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>> Yep. AFAIK the docker:provision puts all karaf directories on the host VM. That's the reason why we're doing it manually. Am I right with this?
> I googled the error message I got: docker: Error response from daemon: No command specified.
> I found this:
> https://serverfault.com/questions/757210/no-command-specified-from-re-imported-docker-image-container
> Is the cause of my error message that docker:provision created an image
> without e.g. the etc directory and expected the docker container to
> provide those directories?
At a little further googling I tried adding a command to the run, to
fire up karaf, but both my guesses ("bin/karaf" and "karaf"), failed:
[node1] (local) root@192.168.0.13 ~
$ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205 bin/karaf
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"bin/karaf\": stat bin/karaf: no such file or directory": unknown.
ERRO[0001] error waiting for container: context canceled
[node1] (local) root@192.168.0.13 ~
$ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205 karaf
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"karaf\": executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled
[node1] (local) root@192.168.0.13 ~
$
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Gerald Kallas <ca...@mailbox.org>:
> Yep. AFAIK the docker:provision puts all karaf directories on the host VM. That's the reason why we're doing it manually. Am I right with this?
I googled the error message I got: docker: Error response from daemon: No command specified.
I found this:
https://serverfault.com/questions/757210/no-command-specified-from-re-imported-docker-image-container
Is the cause of my error message that docker:provision created an image
without e.g. the etc directory and expected the docker container to
provide those directories?
Re: Trying out the karaf docker image
Posted by Gerald Kallas <ca...@mailbox.org>.
Yep. AFAIK the docker:provision puts all karaf directories on the host VM. That's the reason why we're doing it manually. Am I right with this?
> Jean-Baptiste Onofre <jb...@nanthrax.net> hat am 8. April 2020 07:23 geschrieben:
>
>
> It’s more or less what docker:provision is doing ;)
>
> Regards
> JB
>
> > Le 7 avr. 2020 à 17:52, Gerald Kallas <ca...@mailbox.org> a écrit :
> >
> > Hi, that's the way I did w/ Camel on Karaf
> >
> > 1. Start karaf
> >
> > cd /opt
> > unzip /home/karaf/apache-karaf-4.2.7.zip
> > ln -s /opt/apache-karaf* /opt/apache-karaf
> > cd apache-karaf/bin
> > ./karaf
> >
> > 2. Install the needed features (in a 2nd SSH session)
> >
> > cd /opt/apache-karaf/bin
> > ./client < karaf.sh
> >
> > karaf.sh looks like
> >
> > feature:repo-add hawtio 2.9.1
> > feature:repo-add activemq 5.15.11
> > feature:repo-add camel 3.1.0
> > feature:install webconsole hawtio activemq-broker-noweb camel camel-jms jms camel-http camel-jetty camel-swagger-java camel-ftp camel-jackson camel-jsonpath camel-zipfile camel-velocity camel-groovy
> >
> > 3. Package the archive file of the ready-to-run karaf
> >
> > ^D
> > tar -czvf apache-karaf-4.2.7-camel-3.0.1.tgz apache-karaf-4.2.7
> > cp apache-karaf apache-karaf-4.2.7-apache-camel-3.0.1.tgz /home/karaf
> >
> > 4. Build the docker container based on the created archive, the Dockerfile and docker-compose
> >
> > docker-compose up --build -d
> >
> > Dockerfile looks like
> >
> > FROM openjdk:8-jre
> >
> > # Set karaf environment variables
> > ENV KARAF_INSTALL_PATH /opt
> > ENV KARAF_HOME $KARAF_INSTALL_PATH/apache-karaf
> > ENV PATH $PATH:$KARAF_HOME/bin
> >
> > # The karaf_dist can point to a directory or a tarball on the local system
> > ARG karaf_dist=apache-karaf-4.2.7-camel-3.0.1.tgz
> >
> > # Install build dependencies and karaf
> > ADD $karaf_dist $KARAF_INSTALL_PATH
> > RUN set -x && \
> > ln -s $KARAF_INSTALL_PATH/apache-karaf* $KARAF_HOME
> >
> > # Create karaf user
> > RUN groupadd --gid 2000 karaf && \
> > useradd --uid 2000 --create-home --home-dir /var/karaf --gid karaf karaf
> >
> > # Set user permissions
> > RUN mkdir -p /var/karaf/files && \
> > mkdir /opt/apache-karaf/templates && \
> > chown -R karaf:karaf /var/karaf && \
> > chown -R karaf:karaf /opt/apache-karaf*
> >
> > EXPOSE 8101 1099 44444 8181 8443
> > USER karaf
> > CMD ["karaf", "run"]
> >
> > docker-compose looks like
> >
> > services:
> > karaf:
> > container_name: karaf
> > user: "2000"
> > build: .
> > restart: unless-stopped
> > network_mode: bridge
> > ports:
> > - "8101:8101"
> > - "1099:1099"
> > - "44444:44444"
> > - "8181:8181"
> > - "8443:8443"
> > - "8182:8182"
> > - "8444:8444"
> > volumes:
> > - /var/karaf/etc:/opt/apache-karaf/etc
> > - /var/karaf/deploy:/opt/apache-karaf/deploy
> > - /var/karaf/templates:/opt/apache-karaf/templates
> > - /var/karaf/files:/var/casisp/files
> > command: karaf
> > stdin_open: true
> > tty: true
> >
> > So far I'm exposing the 4 directories
> >
> > karaf/etc
> > karaf/deploy
> > karaf/templates (for Velocity templates we're using)
> > karaf/files (for file component consumer and producer)
> >
> > For me it works well. I've to do a little bit of improvement
> >
> > 1. The .m2 Maven directory isn't included yet within the container, so far ist shows some warnings while starting offline
> > 2. Active MQ shows in offline start mode an error because one file is missing
> >
> > Both I'm going to solve within the next couple of days.
> >
> > Best
> > - Gerald
> >
> >> Steinar Bang <sb...@dod.no> hat am 7. April 2020 14:23 geschrieben:
> >>
> >>
> >>>>>>> Steinar Bang <sb...@dod.no>:
> >>
> >>> Is there a way to flush what docker:provision has made?
> >>
> >> Yes. Use the "docker" command on the host (docker installed with
> >> "apt install docker.io" on a debian stable system):
> >> docker rm -vf $(docker ps -a -q)
> >> docker rmi -f $(docker images -a -q)
> >>
> >> Source: https://stackoverflow.com/a/44785784
> >>
> >>> And is there a way to extract the image docker:provision has made and
> >>> make it into something that can be pushed to dockerhub?
> >>
> >> Yes. I did the following:
> >> 1. Created the repo ukelonn-demo on docker hub: https://hub.docker.com/repository/docker/steinarb/ukelonn-demo/tags?page=1
> >>
> >> 2. Ran the commands above to clear out the local docker instance of all images
> >>
> >> 3. Logged the docker instance on my local machine (the one running both
> >> karaf and dockerd):
> >> docker login --username=yourhubusername --email=youremail@company.com
> >>
> >> 4. In karaf, deleted the data directory to start fresh, started karaf
> >> and populated karaf with features, and provisioned the running karaf
> >> (note: this requires my own maven repo, and karaf already had that):
> >> feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
> >> feature:install ukelonn-with-derby
> >> feature:install docker
> >> docker:provision ukelonn-demo
> >>
> >> 5. Ran "docker images" to find the id of the provisioned karaf instance
> >> (at this point it was the only image in the local docker)
> >> sb@lorenzo:~$ docker images
> >> REPOSITORY TAG IMAGE ID CREATED
> >> SIZE
> >> java 8-jre-alpine fdc893b19a14 3 years
> >> ago 108MB
> >> sb@lorenzo:~$
> >>
> >> 6. Created a tag using my dockerhub username, the name of the repo I'd
> >> created and the date and time of day:
> >> sb@lorenzo:~$ docker tag fdc893b19a14 steinarb/ukelonn-demo:202004071205
> >> sb@lorenzo:~$
> >>
> >> 7. Pushed the tag to docker hub:
> >> sb@lorenzo:~$ docker push steinarb/ukelonn-demo:202004071205
> >> The push refers to repository [docker.io/steinarb/ukelonn-demo]
> >> 20dd87a4c2ab: Mounted from library/java
> >> 78075328e0da: Mounted from library/java
> >> 9f8566ee5135: Mounted from library/java
> >> 202004071205: digest:
> >> sha256:6a8cbe4335d1a5711a52912b684e30d6dbfab681a6733440ff7241b05a5deefd
> >> size: 947
> >> sb@lorenzo:~$
> >>
> >> 8. Opened https://labs.play-with-docker.com in a web browser and
> >> clicked on "Start"
> >>
> >> 9. In the command shell, pulled the image from docker hub:
> >> docker pull steinarb/ukelonn-demo:202004071205
> >>
> >> 10. Tried running the image, but that failed with "no command specified":
> >> [node1] (local) root@192.168.0.18 ~
> >> $ docker run -p 8101:8101 -p 8181:8181
> >> steinarb/ukelonn-demo:202004071205
> >> docker: Error response from daemon: No command specified.
> >> See 'docker run --help'.
> >> [node1] (local) root@192.168.0.18 ~
> >> $
> >>
> >> So I'm not all the way yet, but I'm getting closer.
> >>
> >> Source for the docker hub related docker commands: https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html
> >>
> >>> Or do I need to look at more traditional docker image building, using a
> >>> Dockerfile?
> >>
> >> Possibly...? At least if I want to automate the build of docker images.
> >>
> >> But for now it's interesting to see how far I can get just by playing
> >> with some commands.
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
It’s more or less what docker:provision is doing ;)
Regards
JB
> Le 7 avr. 2020 à 17:52, Gerald Kallas <ca...@mailbox.org> a écrit :
>
> Hi, that's the way I did w/ Camel on Karaf
>
> 1. Start karaf
>
> cd /opt
> unzip /home/karaf/apache-karaf-4.2.7.zip
> ln -s /opt/apache-karaf* /opt/apache-karaf
> cd apache-karaf/bin
> ./karaf
>
> 2. Install the needed features (in a 2nd SSH session)
>
> cd /opt/apache-karaf/bin
> ./client < karaf.sh
>
> karaf.sh looks like
>
> feature:repo-add hawtio 2.9.1
> feature:repo-add activemq 5.15.11
> feature:repo-add camel 3.1.0
> feature:install webconsole hawtio activemq-broker-noweb camel camel-jms jms camel-http camel-jetty camel-swagger-java camel-ftp camel-jackson camel-jsonpath camel-zipfile camel-velocity camel-groovy
>
> 3. Package the archive file of the ready-to-run karaf
>
> ^D
> tar -czvf apache-karaf-4.2.7-camel-3.0.1.tgz apache-karaf-4.2.7
> cp apache-karaf apache-karaf-4.2.7-apache-camel-3.0.1.tgz /home/karaf
>
> 4. Build the docker container based on the created archive, the Dockerfile and docker-compose
>
> docker-compose up --build -d
>
> Dockerfile looks like
>
> FROM openjdk:8-jre
>
> # Set karaf environment variables
> ENV KARAF_INSTALL_PATH /opt
> ENV KARAF_HOME $KARAF_INSTALL_PATH/apache-karaf
> ENV PATH $PATH:$KARAF_HOME/bin
>
> # The karaf_dist can point to a directory or a tarball on the local system
> ARG karaf_dist=apache-karaf-4.2.7-camel-3.0.1.tgz
>
> # Install build dependencies and karaf
> ADD $karaf_dist $KARAF_INSTALL_PATH
> RUN set -x && \
> ln -s $KARAF_INSTALL_PATH/apache-karaf* $KARAF_HOME
>
> # Create karaf user
> RUN groupadd --gid 2000 karaf && \
> useradd --uid 2000 --create-home --home-dir /var/karaf --gid karaf karaf
>
> # Set user permissions
> RUN mkdir -p /var/karaf/files && \
> mkdir /opt/apache-karaf/templates && \
> chown -R karaf:karaf /var/karaf && \
> chown -R karaf:karaf /opt/apache-karaf*
>
> EXPOSE 8101 1099 44444 8181 8443
> USER karaf
> CMD ["karaf", "run"]
>
> docker-compose looks like
>
> services:
> karaf:
> container_name: karaf
> user: "2000"
> build: .
> restart: unless-stopped
> network_mode: bridge
> ports:
> - "8101:8101"
> - "1099:1099"
> - "44444:44444"
> - "8181:8181"
> - "8443:8443"
> - "8182:8182"
> - "8444:8444"
> volumes:
> - /var/karaf/etc:/opt/apache-karaf/etc
> - /var/karaf/deploy:/opt/apache-karaf/deploy
> - /var/karaf/templates:/opt/apache-karaf/templates
> - /var/karaf/files:/var/casisp/files
> command: karaf
> stdin_open: true
> tty: true
>
> So far I'm exposing the 4 directories
>
> karaf/etc
> karaf/deploy
> karaf/templates (for Velocity templates we're using)
> karaf/files (for file component consumer and producer)
>
> For me it works well. I've to do a little bit of improvement
>
> 1. The .m2 Maven directory isn't included yet within the container, so far ist shows some warnings while starting offline
> 2. Active MQ shows in offline start mode an error because one file is missing
>
> Both I'm going to solve within the next couple of days.
>
> Best
> - Gerald
>
>> Steinar Bang <sb...@dod.no> hat am 7. April 2020 14:23 geschrieben:
>>
>>
>>>>>>> Steinar Bang <sb...@dod.no>:
>>
>>> Is there a way to flush what docker:provision has made?
>>
>> Yes. Use the "docker" command on the host (docker installed with
>> "apt install docker.io" on a debian stable system):
>> docker rm -vf $(docker ps -a -q)
>> docker rmi -f $(docker images -a -q)
>>
>> Source: https://stackoverflow.com/a/44785784
>>
>>> And is there a way to extract the image docker:provision has made and
>>> make it into something that can be pushed to dockerhub?
>>
>> Yes. I did the following:
>> 1. Created the repo ukelonn-demo on docker hub: https://hub.docker.com/repository/docker/steinarb/ukelonn-demo/tags?page=1
>>
>> 2. Ran the commands above to clear out the local docker instance of all images
>>
>> 3. Logged the docker instance on my local machine (the one running both
>> karaf and dockerd):
>> docker login --username=yourhubusername --email=youremail@company.com
>>
>> 4. In karaf, deleted the data directory to start fresh, started karaf
>> and populated karaf with features, and provisioned the running karaf
>> (note: this requires my own maven repo, and karaf already had that):
>> feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
>> feature:install ukelonn-with-derby
>> feature:install docker
>> docker:provision ukelonn-demo
>>
>> 5. Ran "docker images" to find the id of the provisioned karaf instance
>> (at this point it was the only image in the local docker)
>> sb@lorenzo:~$ docker images
>> REPOSITORY TAG IMAGE ID CREATED
>> SIZE
>> java 8-jre-alpine fdc893b19a14 3 years
>> ago 108MB
>> sb@lorenzo:~$
>>
>> 6. Created a tag using my dockerhub username, the name of the repo I'd
>> created and the date and time of day:
>> sb@lorenzo:~$ docker tag fdc893b19a14 steinarb/ukelonn-demo:202004071205
>> sb@lorenzo:~$
>>
>> 7. Pushed the tag to docker hub:
>> sb@lorenzo:~$ docker push steinarb/ukelonn-demo:202004071205
>> The push refers to repository [docker.io/steinarb/ukelonn-demo]
>> 20dd87a4c2ab: Mounted from library/java
>> 78075328e0da: Mounted from library/java
>> 9f8566ee5135: Mounted from library/java
>> 202004071205: digest:
>> sha256:6a8cbe4335d1a5711a52912b684e30d6dbfab681a6733440ff7241b05a5deefd
>> size: 947
>> sb@lorenzo:~$
>>
>> 8. Opened https://labs.play-with-docker.com in a web browser and
>> clicked on "Start"
>>
>> 9. In the command shell, pulled the image from docker hub:
>> docker pull steinarb/ukelonn-demo:202004071205
>>
>> 10. Tried running the image, but that failed with "no command specified":
>> [node1] (local) root@192.168.0.18 ~
>> $ docker run -p 8101:8101 -p 8181:8181
>> steinarb/ukelonn-demo:202004071205
>> docker: Error response from daemon: No command specified.
>> See 'docker run --help'.
>> [node1] (local) root@192.168.0.18 ~
>> $
>>
>> So I'm not all the way yet, but I'm getting closer.
>>
>> Source for the docker hub related docker commands: https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html
>>
>>> Or do I need to look at more traditional docker image building, using a
>>> Dockerfile?
>>
>> Possibly...? At least if I want to automate the build of docker images.
>>
>> But for now it's interesting to see how far I can get just by playing
>> with some commands.
Re: Trying out the karaf docker image
Posted by Gerald Kallas <ca...@mailbox.org>.
Hi, that's the way I did w/ Camel on Karaf
1. Start karaf
cd /opt
unzip /home/karaf/apache-karaf-4.2.7.zip
ln -s /opt/apache-karaf* /opt/apache-karaf
cd apache-karaf/bin
./karaf
2. Install the needed features (in a 2nd SSH session)
cd /opt/apache-karaf/bin
./client < karaf.sh
karaf.sh looks like
feature:repo-add hawtio 2.9.1
feature:repo-add activemq 5.15.11
feature:repo-add camel 3.1.0
feature:install webconsole hawtio activemq-broker-noweb camel camel-jms jms camel-http camel-jetty camel-swagger-java camel-ftp camel-jackson camel-jsonpath camel-zipfile camel-velocity camel-groovy
3. Package the archive file of the ready-to-run karaf
^D
tar -czvf apache-karaf-4.2.7-camel-3.0.1.tgz apache-karaf-4.2.7
cp apache-karaf apache-karaf-4.2.7-apache-camel-3.0.1.tgz /home/karaf
4. Build the docker container based on the created archive, the Dockerfile and docker-compose
docker-compose up --build -d
Dockerfile looks like
FROM openjdk:8-jre
# Set karaf environment variables
ENV KARAF_INSTALL_PATH /opt
ENV KARAF_HOME $KARAF_INSTALL_PATH/apache-karaf
ENV PATH $PATH:$KARAF_HOME/bin
# The karaf_dist can point to a directory or a tarball on the local system
ARG karaf_dist=apache-karaf-4.2.7-camel-3.0.1.tgz
# Install build dependencies and karaf
ADD $karaf_dist $KARAF_INSTALL_PATH
RUN set -x && \
ln -s $KARAF_INSTALL_PATH/apache-karaf* $KARAF_HOME
# Create karaf user
RUN groupadd --gid 2000 karaf && \
useradd --uid 2000 --create-home --home-dir /var/karaf --gid karaf karaf
# Set user permissions
RUN mkdir -p /var/karaf/files && \
mkdir /opt/apache-karaf/templates && \
chown -R karaf:karaf /var/karaf && \
chown -R karaf:karaf /opt/apache-karaf*
EXPOSE 8101 1099 44444 8181 8443
USER karaf
CMD ["karaf", "run"]
docker-compose looks like
services:
karaf:
container_name: karaf
user: "2000"
build: .
restart: unless-stopped
network_mode: bridge
ports:
- "8101:8101"
- "1099:1099"
- "44444:44444"
- "8181:8181"
- "8443:8443"
- "8182:8182"
- "8444:8444"
volumes:
- /var/karaf/etc:/opt/apache-karaf/etc
- /var/karaf/deploy:/opt/apache-karaf/deploy
- /var/karaf/templates:/opt/apache-karaf/templates
- /var/karaf/files:/var/casisp/files
command: karaf
stdin_open: true
tty: true
So far I'm exposing the 4 directories
karaf/etc
karaf/deploy
karaf/templates (for Velocity templates we're using)
karaf/files (for file component consumer and producer)
For me it works well. I've to do a little bit of improvement
1. The .m2 Maven directory isn't included yet within the container, so far ist shows some warnings while starting offline
2. Active MQ shows in offline start mode an error because one file is missing
Both I'm going to solve within the next couple of days.
Best
- Gerald
> Steinar Bang <sb...@dod.no> hat am 7. April 2020 14:23 geschrieben:
>
>
> >>>>> Steinar Bang <sb...@dod.no>:
>
> > Is there a way to flush what docker:provision has made?
>
> Yes. Use the "docker" command on the host (docker installed with
> "apt install docker.io" on a debian stable system):
> docker rm -vf $(docker ps -a -q)
> docker rmi -f $(docker images -a -q)
>
> Source: https://stackoverflow.com/a/44785784
>
> > And is there a way to extract the image docker:provision has made and
> > make it into something that can be pushed to dockerhub?
>
> Yes. I did the following:
> 1. Created the repo ukelonn-demo on docker hub: https://hub.docker.com/repository/docker/steinarb/ukelonn-demo/tags?page=1
>
> 2. Ran the commands above to clear out the local docker instance of all images
>
> 3. Logged the docker instance on my local machine (the one running both
> karaf and dockerd):
> docker login --username=yourhubusername --email=youremail@company.com
>
> 4. In karaf, deleted the data directory to start fresh, started karaf
> and populated karaf with features, and provisioned the running karaf
> (note: this requires my own maven repo, and karaf already had that):
> feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
> feature:install ukelonn-with-derby
> feature:install docker
> docker:provision ukelonn-demo
>
> 5. Ran "docker images" to find the id of the provisioned karaf instance
> (at this point it was the only image in the local docker)
> sb@lorenzo:~$ docker images
> REPOSITORY TAG IMAGE ID CREATED
> SIZE
> java 8-jre-alpine fdc893b19a14 3 years
> ago 108MB
> sb@lorenzo:~$
>
> 6. Created a tag using my dockerhub username, the name of the repo I'd
> created and the date and time of day:
> sb@lorenzo:~$ docker tag fdc893b19a14 steinarb/ukelonn-demo:202004071205
> sb@lorenzo:~$
>
> 7. Pushed the tag to docker hub:
> sb@lorenzo:~$ docker push steinarb/ukelonn-demo:202004071205
> The push refers to repository [docker.io/steinarb/ukelonn-demo]
> 20dd87a4c2ab: Mounted from library/java
> 78075328e0da: Mounted from library/java
> 9f8566ee5135: Mounted from library/java
> 202004071205: digest:
> sha256:6a8cbe4335d1a5711a52912b684e30d6dbfab681a6733440ff7241b05a5deefd
> size: 947
> sb@lorenzo:~$
>
> 8. Opened https://labs.play-with-docker.com in a web browser and
> clicked on "Start"
>
> 9. In the command shell, pulled the image from docker hub:
> docker pull steinarb/ukelonn-demo:202004071205
>
> 10. Tried running the image, but that failed with "no command specified":
> [node1] (local) root@192.168.0.18 ~
> $ docker run -p 8101:8101 -p 8181:8181
> steinarb/ukelonn-demo:202004071205
> docker: Error response from daemon: No command specified.
> See 'docker run --help'.
> [node1] (local) root@192.168.0.18 ~
> $
>
> So I'm not all the way yet, but I'm getting closer.
>
> Source for the docker hub related docker commands: https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html
>
> > Or do I need to look at more traditional docker image building, using a
> > Dockerfile?
>
> Possibly...? At least if I want to automate the build of docker images.
>
> But for now it's interesting to see how far I can get just by playing
> with some commands.
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
> 10. Tried running the image, but that failed with "no command specified":
> [node1] (local) root@192.168.0.18 ~
> $ docker run -p 8101:8101 -p 8181:8181 steinarb/ukelonn-demo:202004071205
> docker: Error response from daemon: No command specified.
> See 'docker run --help'.
> [node1] (local) root@192.168.0.18 ~
> $
I found the reason for this, I think: karaf is missing from the image
No /opt and no file named something with karaf in the directory tree and
no /opt/apache-karaf/bin in the PATH.
sb@lorenzo:~/workspaces/ws03/ukelonn/docker$ docker run -it steinarb/ukelonn-demo:202004071205 sh
/ # ls -al
total 68
drwxr-xr-x 1 root root 4096 Apr 11 11:20 .
drwxr-xr-x 1 root root 4096 Apr 11 11:20 ..
-rwxr-xr-x 1 root root 0 Apr 11 11:20 .dockerenv
drwxr-xr-x 2 root root 4096 Mar 3 2017 bin
drwxr-xr-x 5 root root 360 Apr 11 11:20 dev
drwxr-xr-x 1 root root 4096 Apr 11 11:20 etc
drwxr-xr-x 2 root root 4096 Mar 3 2017 home
drwxr-xr-x 1 root root 4096 Mar 3 2017 lib
lrwxrwxrwx 1 root root 12 Mar 3 2017 linuxrc -> /bin/busybox
drwxr-xr-x 5 root root 4096 Mar 3 2017 media
drwxr-xr-x 2 root root 4096 Mar 3 2017 mnt
dr-xr-xr-x 231 root root 0 Apr 11 11:20 proc
drwx------ 1 root root 4096 Apr 11 11:20 root
drwxr-xr-x 2 root root 4096 Mar 3 2017 run
drwxr-xr-x 2 root root 4096 Mar 3 2017 sbin
drwxr-xr-x 2 root root 4096 Mar 3 2017 srv
dr-xr-xr-x 13 root root 0 Apr 10 19:53 sys
drwxrwxrwt 2 root root 4096 Mar 3 2017 tmp
drwxr-xr-x 1 root root 4096 Mar 3 2017 usr
drwxr-xr-x 1 root root 4096 Mar 3 2017 var
/ # find . -name \*karaf\*
/ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
/ #
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
> Is there a way to flush what docker:provision has made?
Yes. Use the "docker" command on the host (docker installed with
"apt install docker.io" on a debian stable system):
docker rm -vf $(docker ps -a -q)
docker rmi -f $(docker images -a -q)
Source: https://stackoverflow.com/a/44785784
> And is there a way to extract the image docker:provision has made and
> make it into something that can be pushed to dockerhub?
Yes. I did the following:
1. Created the repo ukelonn-demo on docker hub: https://hub.docker.com/repository/docker/steinarb/ukelonn-demo/tags?page=1
2. Ran the commands above to clear out the local docker instance of all images
3. Logged the docker instance on my local machine (the one running both
karaf and dockerd):
docker login --username=yourhubusername --email=youremail@company.com
4. In karaf, deleted the data directory to start fresh, started karaf
and populated karaf with features, and provisioned the running karaf
(note: this requires my own maven repo, and karaf already had that):
feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
feature:install ukelonn-with-derby
feature:install docker
docker:provision ukelonn-demo
5. Ran "docker images" to find the id of the provisioned karaf instance
(at this point it was the only image in the local docker)
sb@lorenzo:~$ docker images
REPOSITORY TAG IMAGE ID CREATED
SIZE
java 8-jre-alpine fdc893b19a14 3 years
ago 108MB
sb@lorenzo:~$
6. Created a tag using my dockerhub username, the name of the repo I'd
created and the date and time of day:
sb@lorenzo:~$ docker tag fdc893b19a14 steinarb/ukelonn-demo:202004071205
sb@lorenzo:~$
7. Pushed the tag to docker hub:
sb@lorenzo:~$ docker push steinarb/ukelonn-demo:202004071205
The push refers to repository [docker.io/steinarb/ukelonn-demo]
20dd87a4c2ab: Mounted from library/java
78075328e0da: Mounted from library/java
9f8566ee5135: Mounted from library/java
202004071205: digest:
sha256:6a8cbe4335d1a5711a52912b684e30d6dbfab681a6733440ff7241b05a5deefd
size: 947
sb@lorenzo:~$
8. Opened https://labs.play-with-docker.com in a web browser and
clicked on "Start"
9. In the command shell, pulled the image from docker hub:
docker pull steinarb/ukelonn-demo:202004071205
10. Tried running the image, but that failed with "no command specified":
[node1] (local) root@192.168.0.18 ~
$ docker run -p 8101:8101 -p 8181:8181
steinarb/ukelonn-demo:202004071205
docker: Error response from daemon: No command specified.
See 'docker run --help'.
[node1] (local) root@192.168.0.18 ~
$
So I'm not all the way yet, but I'm getting closer.
Source for the docker hub related docker commands: https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html
> Or do I need to look at more traditional docker image building, using a
> Dockerfile?
Possibly...? At least if I want to automate the build of docker images.
But for now it's interesting to see how far I can get just by playing
with some commands.
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
> You just need the docker daemon running on the same machine where Karaf is running: docker feature interacts with the docker daemon (it could be remote also).
> You can pass the URL as argument, for instance docker:provision —url http://localhost:2375
Thanks! ("help docker:provision" doesn't work in 4.2.8 because of the
InvocationTargetException issue (known issue, I know))
Side note: dockerd on GNU/Linux by default doesn't listen to any IP ports,
but only to a domain socket, see e.g. https://stackoverflow.com/a/52170405
Configuring dockerd to listen to a port is only a google search away,
but it may simplify things if the karaf docker support tries connecting
to the domain socket by default...?
Should I make a JIRA for using domain socket by default on GNU/linux?
On the docker:provision: it seemed that the first docker:provision <name>
did the right thing, but the second "docker:provision" just pulled the
the image the first provision had made:
karaf@root()> docker:provision ukelonn-demo
{"status":"Pulling from library/java","id":"8-jre-alpine"}
{"status":"Digest: sha256:6a8cbe4335d1a5711a52912b684e30d6dbfab681a6733440ff7241b05a5deefd"}
{"status":"Status: Image is up to date for java:8-jre-alpine"}
karaf@root()>
It also looks like docker:provision always uses the same docker image: java:8-jre-alpine?
Is there a way to flush what docker:provision has made?
And is there a way to extract the image docker:provision has made and
make it into something that can be pushed to dockerhub?
Or do I need to look at more traditional docker image building, using a
Dockerfile?
Thanks!
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
You just need the docker daemon running on the same machine where Karaf is running: docker feature interacts with the docker daemon (it could be remote also).
You can pass the URL as argument, for instance docker:provision —url http://localhost:2375
Regards
JB
> Le 6 avr. 2020 à 17:06, Steinar Bang <sb...@dod.no> a écrit :
>
>>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
>
>> You can also use the docker feature in karaf and just do
>> docker:provision: it will create a docker image using the current
>> state of the Karaf instance.
>
> Sounds awsome! Can it push the provisioned images to docker hub? Or do
> you need a docker instance running on the same computer as the karaf
> doing the provisioning?
>
> (I tried it briefly and it seemed to require a local docker and I didn't
> find any relevant config in the etc directory after loading the docker
> feature, so I guess it does require a local docker instance...?)
>
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
> You can also use the docker feature in karaf and just do
> docker:provision: it will create a docker image using the current
> state of the Karaf instance.
Sounds awsome! Can it push the provisioned images to docker hub? Or do
you need a docker instance running on the same computer as the karaf
doing the provisioning?
(I tried it briefly and it seemed to require a local docker and I didn't
find any relevant config in the etc directory after loading the docker
feature, so I guess it does require a local docker instance...?)
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi Steinar,
You can also use the docker feature in karaf and just do docker:provision: it will create a docker image using the current state of the Karaf instance.
Regards
JB
> Le 6 avr. 2020 à 12:22, Steinar Bang <sb...@dod.no> a écrit :
>
>>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
>
>> What about creating your own docker file as explained in the blog post ?
>
> I will read the blog post closely and look for this. Thanks!
>
>> Else, juste starting a Karaf instance, changing your running container and tagging.
>
> Hm... that means getting the karaf console prompt, do the commands I
> need to, and then (somehow) tag this...?
>
> Sounds simple so this is something I will have to try. Thanks again!
>
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
> What about creating your own docker file as explained in the blog post ?
I will read the blog post closely and look for this. Thanks!
> Else, juste starting a Karaf instance, changing your running container and tagging.
Hm... that means getting the karaf console prompt, do the commands I
need to, and then (somehow) tag this...?
Sounds simple so this is something I will have to try. Thanks again!
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
What about creating your own docker file as explained in the blog post ?
Else, juste starting a Karaf instance, changing your running container and tagging.
Regards
JB
> Le 6 avr. 2020 à 12:03, Steinar Bang <sb...@dod.no> a écrit :
>
>>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
>
>> Hi,
>> By default, you would need the tty if you want the shell.
>
>> You can find some details here: http://blog.nanthrax.net/?p=839 <http://blog.nanthrax.net/?p=839>
>
>> https://github.com/apache/karaf/tree/master/examples/karaf-docker-example <https://github.com/apache/karaf/tree/master/examples/karaf-docker-example>
>
> Thanks JB!
>
> What I want to do, is:
> 1. Add an extra maven repo
> 2. Run feature:repo-add to add a feature repository
> 3. Run feature:install to install the top feature pulling in everything
>
> What would be the simplest approach?
>
> Create my own Dockerfile inheriting the official karaf dockerfile, then
> creating an image on dockerhub?
>
> Thanks again!
>
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
> Hi,
> By default, you would need the tty if you want the shell.
> You can find some details here: http://blog.nanthrax.net/?p=839 <http://blog.nanthrax.net/?p=839>
> https://github.com/apache/karaf/tree/master/examples/karaf-docker-example <https://github.com/apache/karaf/tree/master/examples/karaf-docker-example>
Thanks JB!
What I want to do, is:
1. Add an extra maven repo
2. Run feature:repo-add to add a feature repository
3. Run feature:install to install the top feature pulling in everything
What would be the simplest approach?
Create my own Dockerfile inheriting the official karaf dockerfile, then
creating an image on dockerhub?
Thanks again!
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,
By default, you would need the tty if you want the shell.
You can find some details here: http://blog.nanthrax.net/?p=839 <http://blog.nanthrax.net/?p=839>
https://github.com/apache/karaf/tree/master/examples/karaf-docker-example <https://github.com/apache/karaf/tree/master/examples/karaf-docker-example>
Regards
JB
> Le 6 avr. 2020 à 11:04, Steinar Bang <sb...@dod.no> a écrit :
>
> I'm using https://labs.pay-with-docker.com which lets anyone with a
> dockerhub user try out a docker container for 4 hours until it's teared
> down.
>
> I've done the following:
> 1. Opened https://labs.play-with-docker.com in a browser
>
> 2. Pulled down docker image 4.2.8:
> docker pull apache/karaf:4.2.8
>
> 3. Did the command "docker images":
> $ docker images
> REPOSITORY TAG IMAGE ID CREATED SIZE
> apache/karaf 4.2.8 e6e9f0f9c039 2 weeks ago 291MB
> [node1] (local) root@192.168.0.48 ~
> $
>
> 4. Tried the command "docker run apache/karaf" but got an error message
> that docker was unable to find tag latest
>
> 5. Tried the command "docker run apache/karaf:4.28" which worked better
>
> 6. I didn't get the prompt back in the command shell
>
> 7. I tried opening port 8101 by clicking on the "Open port" button, but
> that failed
>
> 8. I ssh'd in using the provided hostname and got a docker command
> line:
> ssh ip172-18-0-18-bq5dejroudsg00b7tegg@direct.labs.play-with-docker.com
>
> 9. I tried doing ssh into karaf but failed:
> $ ssh -p 8101 karaf@localhost
> ssh: connect to host localhost port 8101: Connection refused
> [node1] (local) root@192.168.0.48 ~
> $
>
> Is there a way to get a karaf console?
>
> (it doesn't have to be through ssh)
>
> Or is the container karaf without a console?
>
> Thanks!
>
> - Steinar
>
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
> Hi,
> Yeah, that’s another option.
> You are right Karaf 4.2.8 has the jline issue about paster. I proposed a fix on JLine.
> Karaf 4.2.9 will have the fix.
I know. Maybe I'll wait for 4.2.9 before playing further with this? Or
try out the alternatives you listed in the other response?
I downgraded to the 4.2.7 images but got some version issues on the
install (I have bumped pax-web to the 4.2.8 level, but I haven't touched
pax-jdbc).
What I did was:
1. Pull in the 4.2.7 docker image with: docker pull apache/karaf:4.2.7
1. Start the container with "docker run -p 8181:8181 -p 8101:8101 apache/karaf:4.2.7"
2. SSH in to the provided SSH prompt
3. In the SSH prompt, do "ssh -p 8101 karaf@localhost"
Then in the karaf console I tried doing the install:
karaf@root()> config:edit org.ops4j.pax.url.mvn
karaf@root()> config:property-append org.ops4j.pax.url.mvn.repositories ", https://maven.bang.priv.no/repository/@id=ukelonn@snapshots"
karaf@root()> config:property-set org.ops4j.pax.url.mvn.globalUpdatePolicy always
karaf@root()> config:update
karaf@root()> feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
Adding feature url mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
karaf@root()> feature:install ukelonn-with-derby
Error executing command: Error:
Error downloading mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.3_1
Error downloading mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.4.0
Error downloading mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1
Error downloading mvn:org.ops4j.pax.jdbc/pax-jdbc-pool-common/1.4.0
karaf@root()>
Re: Trying out the karaf docker image
Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,
Yeah, that’s another option.
You are right Karaf 4.2.8 has the jline issue about paster. I proposed a fix on JLine.
Karaf 4.2.9 will have the fix.
Regards
JB
> Le 6 avr. 2020 à 11:54, Steinar Bang <sb...@dod.no> a écrit :
>
>>>>>> Steinar Bang <sb...@dod.no>:
>
>> 5. Tried the command "docker run apache/karaf:4.28" which worked better
>
> Adjusted that command slightly:
> docker run -p 8101:8101
>
> and then I was able to ssh in locally on the docker container with
> ssh -p 8101 karaf@localhost
> after first SSH-ing in with the provided command line (the container
> identificator is the username in SSH, so it wasn't possible to ssh
> directly in to karaf).
>
> Hm... with the 4.2.8 ssh copy/paste issues maybe 4.2.7 would have been a
> better choice? I need to paste in some commands to load my test
> application.
>
> And how do I get HTTP out of play-with-docker?
>
> SSH port forwarding or the "Open port" button?
>
> I tried the "Open port" button on port 8101 and it looked like that
> failed because it expected HTTP and found SSH
> SSH-2.0-SSHD-CORE-1.7.0
> Unsupported protocol version: GET / HTTP/1.1
>
> So I guess "Open port" can open an HTTP connection.
>
Re: Trying out the karaf docker image
Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
> 5. Tried the command "docker run apache/karaf:4.28" which worked better
Adjusted that command slightly:
docker run -p 8101:8101
and then I was able to ssh in locally on the docker container with
ssh -p 8101 karaf@localhost
after first SSH-ing in with the provided command line (the container
identificator is the username in SSH, so it wasn't possible to ssh
directly in to karaf).
Hm... with the 4.2.8 ssh copy/paste issues maybe 4.2.7 would have been a
better choice? I need to paste in some commands to load my test
application.
And how do I get HTTP out of play-with-docker?
SSH port forwarding or the "Open port" button?
I tried the "Open port" button on port 8101 and it looked like that
failed because it expected HTTP and found SSH
SSH-2.0-SSHD-CORE-1.7.0
Unsupported protocol version: GET / HTTP/1.1
So I guess "Open port" can open an HTTP connection.