Nov 30, 2017

OpenJDK 9: Limitations/shortcomings of the Jshell

Jshell is a quite powerful tool to do some quick explorations and to write some scripts.

If found the following limitations:
  • No syntax highlighting
  • Only comments with // are allowed
    if you open a script file with
     /**
      *  My comments
      */
    this will work only many warnings.
    |  Error:
    |  illegal start of expression
    |   * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
    |   ^
    |  Error:
    |  illegal start of expression
    |   *
    |   ^
  • The usage of public, static, ... is quite different:
    -> public class MyClass {
    >> public int a;
    >> };
    |  Warning:
    |  Modifier 'public'  not permitted in top-level declarations, ignored
    |  public class MyClass {
    |  ^----^
    |  Added class MyClass this error is corrected:
    |      Modifier 'public'  not permitted in top-level declarations, ignored
    |      public class MyClass {
    |      ^----^

  • If you want to load a scipt with /open then tab completion does not work. The complete path including filename has to be typed / pasted.
  • If you load some example snippet, main(String[] args) is not run by default.
    Just tried with the swing tutorial from oracle:
    jshell Downloads/HelloWorldSwing.java  
    -> String[] mystringarray;
    |  Added variable mystringarray of type String[]

    -> HelloWorldSwing.main(mystringarray); 
  • .. 
to be continued...

Nov 25, 2017

Docker-CE: Creating a small Linux as base OS for running a Docker cluster

After some first steps with docker i wanted to run more than one docker node. The problem is, that i have very limited resources on my laptop.
  • CoreOS (see here)
    consumes about 600MB diskspace
  • UbuntuCore (see here)
    consumes about 1.9GB diskspace
To setup CoreOS you have to learn ignition - otherwise every change is lost after a reboot. For UbuntuCore you have to use an UbuntuOne account to get it running.

I heard, that Alpine Linux is an OS with a very small footprint, so i downloaded the "virtual" image and

mounted it in my virtualbox:


After a short startup i got the following:

This is completely different to all other installation procedures i know. No configuration dialog just a
localhost login:
You have to enter "root" and without a password you get a banner with one important information:
You can setup the system with the command: setup-alpine
This will guide you through a 11 step setup (read the manual). To get a installation with persistent homes, etc. you have to choose the "sys" mode.

And then after a reboot, i have a Linux VM with 170MB.
For my next steps (installing docker, cloning some nodes) this should be the right choice.

[Installing docker is quite easy: remove the # before "edge/community" in /etc/apk/repositories and the run "apk update" and "apk add docker".]



Related posts:

Nov 23, 2017

Docker-CE: Get Started Tutorial - processes / files / HTTP headers

Inside my docker installation on ubuntu server i performed the official docker tutorial part 2: "containers"

Ok. Not really interesting, because the tutorial describes all steps very well (except the point, that you have to install python3-pip and you have to run pip3 and not pip).

Here the interesting part:

After i started the container ("docker run -p 4000:80 friendlyhello") i got the following:
root@ubuntuserver:/var/lib/docker/image# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
6f187950452f        friendlyhello       "python app.py"     2 hours ago         Up 2 hours          0.0.0.0:4000->80/tcp   keen_bartik
and the OS displayed

root@ubuntuserver:/var/lib/docker/image# ps x |grep docker
 5852 ?        Ssl    0:18 /usr/bin/dockerd -H fd://
 5867 ?        Ssl    0:10 docker-containerd --config /var/run/docker/containerd/containerd.toml
17100 ?        Sl     0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 4000 -container-ip 172.17.0.2 -container-port 80
17105 ?        Sl     0:00 docker-containerd-shim --namespace moby --workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/6f187950452f501cf18d7efd673e8305d6c9752c58acfb14918ae37341952a11 --address /var/run/docker/containerd/docker-containerd.sock --runtime-root /var/run/docker/runtime-runc
So the containerid is part of the directory which is loaded with "--workdir"

The HTTP headers showup the following:

So the process "docker-proxy-proto" does only a portforwarding from port 4000 to port 80 and the webserver is provided by python:
Content-Type: text/html; charset=utf-8
Content-Length: 118
Server: Werkzeug/0.12.2 Python/2.7.14
Date: Sun, 19 Nov 2017 12:20:42 GMT
Here the process tree:
# pstree -al
systemd
  ├─dockerd -H fd://
  │   ├─docker-containe --config /var/run/docker/containerd/containerd.toml
  │   │   ├─docker-containe --namespace moby --workdir /var/lib/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/6f187950452f501cf18d7efd673e8305d6c9752c58acfb14918ae37341952a11 --address /var/run/docker/containerd/docker-containerd.sock --runtime-root /var/run/docker/runtime-runc
  │   │   │   ├─python app.py
  │   │   │   └─9*[{docker-containe}]
  │   │   └─7*[{docker-containe}]
  │   ├─docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 4000 -container-ip 172.17.0.2 -container-port 80
  │   │   └─4*[{docker-proxy}]
  │   └─9*[{dockerd}]
Note that this container has the ip 172.17.0.2. This is part of a private network and the ubuntu server has the ip
# ip address show docker0
3: docker0: mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:f4:04:06:3d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever

If you start the container twice
root@ubuntuserver:~/dockerapp# docker run -d -p 4000:80 friendlyhello
aebe1a25dd2dda1c36c5cdd46bbdc138099711c885a7fb270b9981301a66fbd9
root@ubuntuserver:~/dockerapp# docker run -d -p 4001:80 friendlyhello
59276d1e15d7a636dbcf4eb599f7a948365eed656d93d47097999bee9b25db6b
there are two docker-proxies running:
# ps aux|grep docker-proxy
root      1286  0.0  0.3 304928  3084 ?        Sl   16:16   0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 4000 -container-ip 172.17.0.2 -container-port 80
root      1385  0.0  0.2 304928  2880 ?        Sl   16:16   0:00 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 4001 -container-ip 172.17.0.3 -container-port 80

Related posts:

Nov 18, 2017

Docker-CE: initial configuration

After installing docker to a ubuntu server i was keen what kind of processes and files are there.
# ps x|grep docker
 5852 ?        Ssl    0:05 /usr/bin/dockerd -H fd://
 5867 ?        Ssl    0:04 docker-containerd --config /var/run/docker/containerd/containerd.toml
So the inital configuration is not stored in /etc.

The configuration file looks like this:
# cat /var/run/docker/containerd/containerd.toml
root = "/var/lib/docker/containerd/daemon"
state = "/var/run/docker/containerd/daemon"
subreaper = false
oom_score = -500

[grpc]
  address = "/var/run/docker/containerd/docker-containerd.sock"
  uid = 0
  gid = 0

[debug]
  address = "/var/run/docker/containerd/docker-containerd-debug.sock"
  uid = 0
  gid = 0
  level = "info"

[metrics]
  address = ""

[cgroup]
  path = ""

[plugins]
  [plugins.linux]
    shim = "docker-containerd-shim"
    runtime = "docker-runc"
    runtime_root = "/var/lib/docker/runc"
    no_shim = false
    shim_debug = false
    shim_no_newns = false
The directory /var/run/docker/containerd/daemon seems to be important, so let's take a look:
# find /var/run/docker/containerd/daemon
/var/run/docker/containerd/daemon
/var/run/docker/containerd/daemon/io.containerd.runtime.v1.linux
/var/run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby
But theese entries are only directories...

So what about /var/lib? Here we go:
# find /var/lib/docker/ -maxdepth 1
/var/lib/docker/
/var/lib/docker/overlay2
/var/lib/docker/swarm
/var/lib/docker/image
/var/lib/docker/tmp
/var/lib/docker/runtimes
/var/lib/docker/trust
/var/lib/docker/plugins
/var/lib/docker/containerd
/var/lib/docker/containers
/var/lib/docker/builder
/var/lib/docker/volumes
/var/lib/docker/network
Within the directory containers you can find information about the containers which run / ran on your docker system:

# ls -l
insgesamt 12
drwx------ 4 root root 4096 Nov 16 22:12 0c7567bb965449f5f2f3dfadfc38f0226bdb42cc6d46daa4641042090e0405c7
drwx------ 4 root root 4096 Nov 16 22:57 28b7f70147aabc94bd174ce7ad7f5d48ed5610ffaa21733d3549ee6e998ee7c3
drwx------ 4 root root 4096 Nov 16 21:59 2db1c3ed1dafc85369536c382e02b6a23e5d134d2ba3d56a738f3441fb624b04
 The first characters of the directories match the container-id:
# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                  PORTS               NAMES
28b7f70147aa        hello-world         "/hello"            2 days ago          Exited (0) 2 days ago                       trusting_bartik
0c7567bb9654        hello-world         "/hello"            2 days ago          Exited (0) 2 days ago                       festive_wozniak
2db1c3ed1daf        hello-world         "/hello"            2 days ago          Exited (0) 2 days ago                       epic_tesla


Related posts: