How to update Docker CLI client for Windows

Sometimes you need to update your Docker Client for Windows, which was installed with Docker Toolbox. But you can’t find an easy way to do that (see this thread for example).

Docker Toolbox is the legacy way to use Docker on Windows, using VirtualBox, but it’s still useful when :

Upgrading the Docker Engine (server side) is easy with docker-machine. Just use :

docker-machine upgrade <machine_name>

and it will try to download the latest release (boot2docker.iso, working on VirtualBox) on https://github.com/boot2docker/boot2docker/releases/latest .

To update Docker Client, you could reinstall Docker Toolbox, but it’s quite cumbersome. In fact you can rebuild docker.exe from sources. After Docker Toolbox installation, this file can normally be found in « C:\Program Files\Docker Toolbox\docker.exe« .

How to build an exe for Windows

I found in Docker Toolbox sources how docker.exe was built and embedded.
It’s partly in this line :

RUN cp /go/src/github.com/docker/cli/build/docker-windows-amd64 docker.exe

Then I found that the CLI tool is in this repo : https://github.com/docker/docker-ce, under components/cli . So we can follow the instructions to build it.

For example, if you want to build docker.exe for a given version, let’s say « 18.05.0-ce », you can follow this script :

Install the new exe

Then you can backup your old docker.exe in « C:\Program Files\Docker Toolbox\docker.exe » and replace it with the new one.

Test the new version

Check that the new version is working :

> docker --version
Docker version 18.05.0-ce, build
Publicités

Docker : my container was OOMKilled

Intro

Un container Docker dispose de ressources limitées à sa création (cpu, mémoire…). Il se peut que le container crashe subitement s’il dispose de ressources insuffisantes. Dans le cas d’un manque de mémoire, on aura donc une erreur du type OOMKilled.

Vérification de l’état du container

Toutes les informations sur l’état du container :

docker inspect --format="{{json .State}}" $INSTANCE_ID

Retourne par exemple :

{"Status":"running","Running":true,"Paused":false,"Restarting":false,
"OOMKilled":false,"Dead":false,"Pid":2862,"ExitCode":0,"Error":"",
"StartedAt":"2018-06-13T13:41:47.205270058Z","FinishedAt":"2018-06-13T13:39:41.797869481Z"}

Flag OOMKilled :

docker inspect --format='{{.State.OOMKilled}}' $INSTANCE_ID

Retourne true si OOM

Flag ExitCode :

docker inspect --format='{{.State.ExitCode}}' $INSTANCE_ID

Retourne 137 en cas de crash dû à OOM.
137 = (128+9) Container received a SIGKILL

Tracer le problème dans une JVM

Au sein d’une JVM, on peut essayer de tracer l’erreur.

Voir par exemple les paramètres :

java -XX:+PrintFlagsFinal -version | grep -i outofmemoryerror

bool CrashOnOutOfMemoryError = false {product}
bool ExitOnOutOfMemoryError = false {product}
bool HeapDumpOnOutOfMemoryError = false {manageable}
ccstrlist OnOutOfMemoryError = {product}

Une version de JVM container-friendly

Des paramètres ont été rajoutés dans les versions récentes de la JVM, pour essayer d’adapter les paramètres mémoire de la JVM (Xms, Xmx) avec ceux du container dans lequel elle s’exécute.

A partir de JDK 8u131+ et JDK 9 on trouve donc de nouveaux paramètres, notamment pour la mémoire :

-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

Tickets concernés

Références

Configure Git to use with a proxy and switching back

git-logo-2color

Sometimes it can be useful and even necessary to configure Git to use a proxy in the global configuration.
It’s a easy as (https://git-scm.com/docs/git-config#git-config-httpproxy) :
git config --global http.proxy host:port

This configuration will then be written in ~/.gitconfig.

You will then have something like that :

[user]
	name = Me
	email = me@company.com
[http]
	proxy = host:port

Then one day you want to switch and use a different proxy, or none.

But it’s not obvious to configure, regarding the official documentation (https://git-scm.com/docs/git-config).

I could simply unset the proxy if I want to use none, like this :
git config --global --unset http.proxy

I also tried to create aliases to switch to another configuration, like :

  1. git config --global alias.proxy-local 'config --local http.proxy host:port'
  2. git config --global alias.noproxy-local 'config --local http.proxy none'

So I can use ‘git proxy-local’ or ‘git noproxy-local’ depending of the project.

But it could be more practical. By searching further I found a way to configure the proxy depending on the URL. Within the configuration we can use this format to configure options : http.<url>.* (https://git-scm.com/docs/git-config#git-config-httplturlgt).
Some examples are also documented like this :

; HTTP
[http]
	sslVerify
[http "https://weak.example.com"]
	sslVerify = false
	cookieFile = /tmp/cookie.txt

So that way you can configure a proxy by default, and for some URL use another proxy or none :

; Use a proxy by default
[http]
	proxy = host:port
; Use no proxy on internal server
[http "http://myserver.mycompany/"]
	proxy = 

That’s it !

Generating a link to your issue tracker with IntelliJ

Sometimes it’s a good practice to post a commit message to your VCS (version control system), including a pattern with the issue number.

For example, you could commit changes towards Git or Subversion, with this commit message : « I fixed this nasty bug : #123 ».

And it could be nice to automatically generate a link to your issue tracker directly inside your favorite Java IDE.

Here’s how to do with IntelliJ IDEA :

  • Go to File > Settings > Version Control > Issue Navigation
  • Then add an item : here you have to fill in the issue ID (regex), and the issue link that will be generated (regex with replacement of the capturing group)

The dialog box you’ll get looks like this :

add-issue-nav-link

If you want to capture just a part of the regex, you can use the capturing groups.
Let’s say the pattern you use is « #issue-number », but you want to exclude the « # » from the URL generated. So in this case you will use a regex with one non-capturing group, and a capturing group.
So the issue ID regex will be : (?:#)([0-9]+)
And the issue link will be : http://my-issue-tracker/$1

That way, you’ll be able so see a clickable link in the Version Control window (ALT+9).

See also :

JMX MBean provided with Oracle JDBC Driver

I discovered that Oracle added a JMX MBean in Oracle JDBC Driver.
It’s called « Diagnosability Management ».

Doc for version 11g :
https://docs.oracle.com/cd/B28359_01/java.111/b31224/diagnose.htm#CIAIEEFF

Resume :

The JDBC diagnosability management feature introduces an MBean, oracle.jdbc.driver.OracleDiagnosabilityMBean. This MBean provides means to enable and disable JDBC logging.

Description of the MBean :

  • Name :
    • Domain : com.oracle.jdbc
    • Name : org.jboss.classloader.spi.base.BaseClassLoader
    • Type : diagnosability
  • Attribute Name : LoggingEnabled (boolean)

Logging with Oracle JDBC Driver

Doc for version 11g :
https://docs.oracle.com/cd/B28359_01/java.111/b31224/diagnose.htm#CIAGBGFI

Logging is done using java.util.logging package provided by Java SE.

To get log output, you must use the debug JAR files, which are indicated with a « _g » in the file name, like ojdbc5_g.jar or ojdbc6_g.jar. The debug JAR file must be included in the CLASSPATH environment variable.

Resume :

This feature logs information about events that occur when JDBC driver code runs. Events can include user-visible events, such as SQL exceptions, running of SQL statements, and detailed JDBC internal events, such as entry to and exit from internal JDBC methods. Users can enable this feature to log specific events or all the events.