Instantly share code, notes, and snippets.

kekru / Docker connect to remote
Last active Feb 18, 2019
Connect to another host with your docker client, without modifying your local Docker installation
View Docker connect to remote

Run commands on remote Docker host

This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

Enable Docker Remote API

First be sure to enable the Docker Remote API on the remote host.

This can easily be done with a container.
For HTTP connection use jarkt/docker-remote-api.
For HTTPS connection use whiledo/docker-remote-api-tls.

kekru / 1-Enable Docker Remote API with TLS client
Last active Feb 18, 2019
Docker Remote API with client verification via daemon.json
View 1-Enable Docker Remote API with TLS client

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

kekru / add CA cert on CentOS Debian
Last active Feb 17, 2019
Add CA cert to local trust store on CentOS, Debian or Ubuntu
View add CA cert on CentOS Debian
  • Open a webpage that uses the CA with Firefox
  • Click the lock-icon in the addressbar -> show information -> show certificate
  • the certificate viewer will open
  • click details and choose the certificate of the certificate-chain, you want to import to CentOS
  • click "Export..." and save it as .crt file
  • Copy the .crt file to /etc/pki/ca-trust/source/anchors on your CentOS machine
  • run update-ca-trust extract
  • test it with wget
kekru / Springboot.Dockerfile
Last active Feb 9, 2019
Spring Boot Dockerfile template
View Springboot.Dockerfile
FROM openjdk:8-jre
RUN echo "Europe/Berlin" > /etc/timezone && dpkg-reconfigure -f noninteractive tzdata
RUN mkdir /data
ADD myapp.jar /data/myapp.jar
ENV springprofiles="" \
ENTRYPOINT MAXRAM=$(expr `cat /sys/fs/cgroup/memory/memory.limit_in_bytes` / 1024 / 1024) && \
View gist:3fe759fc98c432b1cbf6507b5bc107d0
/////////// changes for pom.xml
kekru / 1-WSL and Docker for
Last active Jan 19, 2019
Windows 10 Subsystem for Linux combined with Docker for Windows
View 1-WSL and Docker for

Using Windows Subsystem for Linux combined with Docker for Windows

Docker CE for Windows

  • Install Docker CE for Windows
  • Go to Docker for Windows Settings -> General and enable Expose daemon on tcp://localhost:2375 without TLS.
    This will enable the Docker remote API for requests, coming from localhost, not from another computer in your network. A TLS secured version is not yet supported in Docker for Windows. See for more information. I also tried a daemon.json file with options tlscacert, tlscert, tlskey and tlsverify, but Docker for Windows crashed on booting.

Install Windows Subsystem for Linux (WSL)

kekru /
Last active Oct 28, 2018
Ubuntu map keybooard special key

My low cost keyboard does not have a less/greater/pipe key....
So I mapped a special key, to the less/greater/pipe key

# find out the keycode of the special key, for me it was 148
# set Strg_r to Mode_switch -> Strg_r + special key will print pipe
sudo xmodmap -e "keycode 0x69 = Mode_switch Mode_switch Mode_switch Mode_switch" 
# set key binding for special key. Replace the keycode with your keycode  
sudo xmodmap -e "keycode 148 = less greater bar"
kekru / Vagrant create local
Last active Aug 10, 2018
Vagrant: Create local box
View Vagrant create local

Create box

This is how to install something in a VM and export it as a Vagrant box and use it locally.

First copy the Vagrantfile from below and change the box to the box you want as a base.

Run vagrant up to create the Virtual Machine and vagrant ssh to login.
On Windows you might have to put ssh.exe to your %PATH%. If you have installed git, you can use C:\Program Files\Git\usr\bin You can also login via Putty on host: "localhost", Port "2222", login: "vagrant", password: "vagrant".

kekru / register Hibernate EventListener in
Created Sep 22, 2016
Register a Hibernate Envers EventListener in Spring Boot (Hibernate 4, Hibernate 5)
View register Hibernate EventListener in

Hibernate 4 introduced a new Audit API for event listening.
org.hibernate.envers.event.AuditEventListener was replaced by org.hibernate.event.spi.*, for example org.hibernate.event.spi.PostDeleteEventListener.

First create your custom listener. Example: You want do disable auditing for delete operations.

import org.hibernate.envers.event.spi.EnversPostDeleteEventListenerImpl;
import org.hibernate.event.spi.PostDeleteEvent;

public class MyAuditListener extends EnversPostDeleteEventListenerImpl {