>>>>> Steinar Bang <[email protected]>:

> 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 protected]

 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) [email protected] ~
     $ 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) [email protected] ~
     $

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.

Reply via email to