On Wed, Jul 10, 2019 at 4:07 PM Waldek Kozaczuk <jwkozac...@gmail.com> wrote:
> OSv cannot run Docker containers and probably never will. But It turns out > one could quite easily build tooling around running Docker images. If you > think about it in order to un an image as a container, docker has to > "unflatten" it into chroot'ed directory. So what if we somehow extracted > the files from that image and build OSv image from it. > > I was browsing the internet and came across the tool called "undocker" > built-in Python. Here is an article about what it does - > https://blog.oddbit.com/post/2015-02-13-unpacking-docker-images/ - and > the project itself - https://github.com/larsks/undocker/. > > I experimented with it a bit and here is how (more less) I got a working > image of Java 12 running on OSv: > > docker pull adoptopenjdk/openjdk12:x86_64-ubuntu-jre-12.0.1_12 > docker save adoptopenjdk/openjdk12:x86_64-ubuntu-jre-12.0.1_12 | > ~/projects/undocker/undocker.py -o openjdk12 # To extract entire image to > openjdk12 dir > > # Or just single layer - last one > docker save adoptopenjdk/openjdk12:x86_64-ubuntu-jre-12.0.1_12 | > ~/projects/undocker/undocker.py --layers > >>0ddb62468773ea4644c87eca19f361e3f6d602b3e816665e820901e0b85fe934 > >>dfbb0b83b1fb79731b51f2614422e016c5f35cbdd288074727df9d90ffee7344 > >>1001e9643834372626cddff17a762720d05b8520e36acd3a2815e626d2e449fc > >>427e8dd10b4bb425d3d51e2947997f8756f257bb2b3519965282f0dfd37076ce > >>a1a40aee38d5acb2faf6dddc98611b2c7a202ac792069f6ecffcaf4ee3ec9871 > >>73ca3efe6a18c189325258702e6c076da16fed67e052ae6d3cf017494e5e2b3e #Use > the last one that contains JDK only > > docker save adoptopenjdk/openjdk12:x86_64-ubuntu-jre-12.0.1_12 | > ~/projects/undocker/undocker.py -o openjdk12 -l > 73ca3efe6a18c189325258702e6c076da16fed67e052ae6d3cf017494e5e2b3e > > # Use scripts/manifest_from_host.sh to build an image > ./scripts/manifest_from_host.sh -rw $PATH_TO/openjdk12/ > ./scripts/build image=java-example --append-manifest > ./scripts/run.py -e '/opt/java/openjdk/bin/java -cp /java-example Hello !' > > Typically you would not want entire Docker image as it looks like this > unpacked and is ~ 260MB in size: > drwxr-xr-x 21 wkozaczuk wkozaczuk 4096 Jul 10 00:52 ./ > drwxr-xr-x 4 wkozaczuk wkozaczuk 4096 Jul 10 01:02 ../ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 12 12:55 bin/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Apr 24 2018 boot/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 12 12:55 dev/ > drwxr-xr-x 33 wkozaczuk wkozaczuk 4096 Jul 9 14:49 etc/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Apr 24 2018 home/ > drwxr-xr-x 8 wkozaczuk wkozaczuk 4096 May 23 2017 lib/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 12 12:55 lib64/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 12 12:54 media/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 12 12:54 mnt/ > drwxr-xr-x 3 wkozaczuk wkozaczuk 4096 Jul 9 14:49 opt/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Apr 24 2018 proc/ > drwx------ 2 wkozaczuk wkozaczuk 4096 Jun 12 12:55 root/ > drwxr-xr-x 5 wkozaczuk wkozaczuk 4096 Jun 18 18:51 run/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 18 18:51 sbin/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Jun 12 12:54 srv/ > drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Apr 24 2018 sys/ > drwxrwxrwt 2 wkozaczuk wkozaczuk 4096 Jul 9 14:49 tmp/ > drwxr-xr-x 10 wkozaczuk wkozaczuk 4096 Jun 12 12:54 usr/ > drwxr-xr-x 11 wkozaczuk wkozaczuk 4096 Jun 12 12:55 var/ > > Instead in this case need only single last layer of it: > 8399768 4 drwxr-xr-x 4 wkozaczuk wkozaczuk 4096 Jul 10 09:05 . > 8402714 4 drwxrwxrwt 2 wkozaczuk wkozaczuk 4096 Jul 9 14:49 > ./tmp > 8402715 0 -rw-r--r-- 1 wkozaczuk wkozaczuk 0 Jul 10 09:05 > ./bla > 8402713 4 drwxr-xr-x 3 wkozaczuk wkozaczuk 4096 Jul 9 14:49 > ./opt > 9437503 4 drwxr-xr-x 3 wkozaczuk wkozaczuk 4096 Jul 9 14:49 > ./opt/java > 9437504 4 drwxr-xr-x 6 wkozaczuk wkozaczuk 4096 Jul 9 14:49 > ./opt/java/openjdk > 9440658 4 -rw-r--r-- 1 wkozaczuk wkozaczuk 999 Apr 20 13:03 > ./opt/java/openjdk/release > 9437505 4 drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Apr 20 13:03 > ./opt/java/openjdk/bin > 9437515 116 -rwxr-xr-x 1 wkozaczuk wkozaczuk 118088 Apr 20 13:03 > ./opt/java/openjdk/bin/unpack200 > 9437508 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8912 Apr 20 13:03 > ./opt/java/openjdk/bin/jfr > 9437513 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8912 Apr 20 13:03 > ./opt/java/openjdk/bin/rmid > 9437509 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8960 Apr 20 13:03 > ./opt/java/openjdk/bin/jjs > 9437511 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8912 Apr 20 13:03 > ./opt/java/openjdk/bin/keytool > 9437512 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8912 Apr 20 13:03 > ./opt/java/openjdk/bin/pack200 > 9437514 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8912 Apr 20 13:03 > ./opt/java/openjdk/bin/rmiregistry > 9437510 16 -rwxr-xr-x 1 wkozaczuk wkozaczuk 13056 Apr 20 13:03 > ./opt/java/openjdk/bin/jrunscript > 9437506 16 -rwxr-xr-x 1 wkozaczuk wkozaczuk 13104 Apr 20 13:03 > ./opt/java/openjdk/bin/jaotc > 9437507 12 -rwxr-xr-x 1 wkozaczuk wkozaczuk 8888 Apr 20 13:03 > ./opt/java/openjdk/bin/java > 9437516 4 drwxr-xr-x 5 wkozaczuk wkozaczuk 4096 Apr 20 13:03 > ./opt/java/openjdk/conf > 9437518 4 drwxr-xr-x 2 wkozaczuk wkozaczuk 4096 Apr 20 13:03 > ./opt/java/openjdk/conf/management > 9437519 4 -rw-r--r-- 1 wkozaczuk wkozaczuk 3997 Apr 20 13:03 > ./opt/java/openjdk/conf/management/jmxremote.access > 9437521 16 -rw-r--r-- 1 wkozaczuk wkozaczuk 14292 Apr 20 13:03 > ./opt/java/openjdk/conf/management/management.properties > 9437520 8 -rw-r--r-- 1 wkozaczuk wkozaczuk 5690 Apr 20 13:03 > ./opt/java/openjdk/conf/management/jmxremote.password.template > .... > > which is 130MB in size. > > What is the best way to goe about I do not know yet. What do you think? > One thing you can do is write a script which takes the entire root directory and then *excludes* or *includes* various regular expressions from it. So for example you don't need glibc, the shell, manual pages, and a lot of other stuff that may be in the image, and only keep the rest. Also, since you will exclude the init scripts and shell scripts normally used to run the application (they won't work out of the box on OSv...) you'll also need to specify a different way - some command line - of how to run the application. -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/CANEVyjvsiz-wdUKqbsXFKBP4v9yowvaWx6Xmk-RHLPsj9t3A1w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.