Tuesday 30 May 2017

Running a .NET Core Console Application on a Linux container with Docker for Windows

The network information can be determined by running:
docker inspect e8047deb24a8 > docker-image-e8047deb24a8.txt

The file system can be exported by running
docker export e8047deb24a8 > C:\Temp\1\a

The network can be seen with
docker network ls

and inspected in detail with:
docker exec -it --privileged d79699256379 cat /etc/hosts

I added extra_hosts to the docker-compose.vs.debug.yml file

version: '2'

    image: changefeedclient.core:dev
        source: ${DOCKER_BUILD_SOURCE}
      - ./ChangeFeedClient.Core:/app
      - ~/.nuget/packages:/root/.nuget/packages:ro
      - ~/clrdbg:/clrdbg:ro
    entrypoint: tail -f /dev/null
      - "com.microsoft.visualstudio.targetoperatingsystem=linux"
      - "myhost:"

and ran again
docker exec -it --privileged d79699256379 cat /etc/hosts

which showed myhost in the host file.
I then ran 

docker exec -it --privileged a557749dded2 ping myhost

which worked!

I could then access the test webserver on port 81 on the host:
docker exec -it --privileged a557749dded2 curl myhost:81

The host is running OpenSSL. You can check certificates with:
docker exec -it a557749dded2 openssl s_client -connect myhost:8081

Required steps:
1. Set up the route on the container to allow the container to see the host.
2. Set up a proxy on localhost to proxy connections to
3. Install the CA certificate onto Linux

PS C:\Users\AndrewPotts> docker exec -it --privileged a557749dded2 update-ca-certificates
Updating certificates in /etc/ssl/certs... unable to load certificate
140565325366928:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:Expecting: TRUSTED CERTIFICATE
unable to load certificate
140089052296848:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:Expecting: TRUSTED CERTIFICATE
WARNING: Skipping duplicate certificate CharlesProxy.pem
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....done.

Import Charles Proxy certificate into the container.
In Charles Proxy, select Help > SSL Proxying > Install Charles Certificate.
The certificate is displayed.
Click the Details tab.
Copy to File.
Select Base-64 Encoded X.509 (CER).
Save it to a file.

Convert the CER into Unix format.
Using Notepad++, Edit -> EOL Conversion -> Unix/OSX Format.

Copy the certificate to the container.

docker cp C:\Users\AndrewPotts\Documents\DocumentDB\CharlesProxy.cer a557749dded2:/usr/local/share/ca-certificates/CharlesProxy.crt

Update the certificates.

docker exec -it --privileged a557749dded2 ls update-ca-certificates

The server responds with in the response body which throws the client.
Set up a rewrite rule to rewrite to

Tried to configured DocDb to run on different direct ports

Changed the connection policy to gateway

Version of the emulator supports network connections!
By setting the following command-line parameters you can connect to the emulator from within a container:

/AllowNetworkAccess /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

Note that the containers certificate uses the machine name as the CN, so it is important you set the extra_host and the host file entry to map a relationship between the gateway IP and the certificate CN.

Also, to avoid the SSL self-signed certificate validation errors, you can set the connection policy on the client:


Monday 29 May 2017

Java on Pi: adding JAR library

Note that colons, not semicolons, separate the classpath parameters when compiling a Java program. You may also need to run as sudo if you are accessing any protected folders.

javac -cp ".:/opt/pi4j/lib/pi4j-core.jar" BME280.java


javac -classpath '.:classes:*:classes:/opt/pi4j/lib/*' -d . /home/pi/Java_Weather/BME280.java

Note that you still need the classpath when running the code:

java -cp ".:/opt/pi4j/lib/*:" BME280

or explicitly defining the path:
java -cp ".:/opt/pi4j/lib/*:/home/pi/Java_Weather/:" BME280

Friday 26 May 2017

Disabling VNC server on Raspberry Pi

I noticed /var/log/user was FULL of errors about

 vncserver-x11[3900]: AgentInitCheck: no response from agent

So I disabled the service on boot with:
sudo update-rc.d vncserver-x11-serviced disable

Raspberry Pi Zero disconnect from WiFi

My Raspberry Pi Zero was disconnecting from the Wifi on a daily basis.
In the end I could see a message in /var/log/message indicating an Auth error when trying to reconnect to the Wifi.

Currently to solve this I have scheduled a nightly reboot.

Saturday 20 May 2017

BM280, Raspberry PI, I2C, "i2cdetect -y 1": No such file or directory

When following this article to set up a temperature sensor on my Raspbery Pi, I had to do a couple of additional steps:

1. Configure I2C on the Pi. I did this by following this article and using raspbi-config and the advanced settings to enable I2C.

2. When running the command to check the I2C interface, I executed
i2cdetect -y 1

This returned "No such file or directory".

This required the following to be added to /etc/modules and reboot


3. After this "i2cdetect -y 1" was working, but not detecting any hardware. (It show 77 in the list somewhere).

The next step was because the boot needed to configure some hardware pins.


If you are running a recent Raspberry Pi (3.18 kernel or higher) you will also need to update the /boot/config.txt file. Edit it with sudo nano /boot/config.txt and add the text
at the bottom. note that the "1" in "i2c1" is a one not an L!

4. This still didn't fix it.

I was running on kernel 3.18.

I did a
apt-get dist-upgrade


and then went back into raspi-config and disabled "Device Tree".

This time I got UU when running i2cdetect.

Friday 19 May 2017

VS.NET with Docker Compose - client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

When creating an ASPNETCore project with Docker Compose support, on building I got the following error:

docker-compose -f "C:\Source Code\Test Projects\AspNetCore\docker-compose.yml" -f "C:\Source Code\Test Projects\AspNetCore\docker-compose.override.yml" -f "C:\Source Code\Test Projects\AspNetCore\docker-compose.vs.release.yml" -p dockercompose4184813946 kill
    client version 1.22 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Yet running docker-compose version in a PowerShell prompt returns:

 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Tue Mar 28 00:40:02 2017
 OS/Arch:      windows/amd64

Thankfully this article solves the problem. Because my tools are so new, there is an incompatibility with slightly older files produced by the VS.NET template.

The solution is to add
version: '2.1'
to the top of the docker-compose.yml file.

Friday 12 May 2017

Windows 10 Start Menu missing icons and enter key not working

I had a strange problem where the Windows 10 lost all the icons in the start menu and when I could locate an icon pressing ENTER wouldn't work.

I restarted, logged out, etc and that didn't fix it.

Fortunately, running powershell as an administrator and executing sfc /scannow seemed to fix the problem.


Thursday 4 May 2017

Fixing the CSGo SDK

I had a phone call from a very concerned son last night who was upset that the Counter Strike Go SDK wasn't working: when it launched it just displayed an empty dialog box and nothing happened.

So I googled around and found this link:

To fix it, MediaList.txt into the \Counter-Strike Global Offensive\bin\sdklauncher folder.
You may also need to put sourcescheme.res in \Counter-Strike Global Offensive\platform\resource.

The contents of MediaList.txt are:

   index 1
   image icon_hl2_media // goes in vgui/notes.tga
   index 2
   image icon_document
   index 3
   image icon_soft
   index 4
   image icon_hammer
   index 5
   image icon_faceposer
   index 6
   image icon_hlmv
   index 7
   image icon_scenemanager
   index 8
   image icon_weblink
   index 9
   image icon_create
   index 10
   image icon_refresh
   index 11
   image icon_reset
   index 12
   image icon_folder
   index 13
   image icon_files

   id  1
   Name "Applications"

    Title   "Hammer World Editor"
    Program   "hammer.exe -nop4"
    Image   4
    Title   "Model Viewer"
    Program   "hlmv.exe"
    Image   6
    Title   "Face Poser"
    Program   "hlfaceposer.exe -nop4"
    Image   5
   id  3
   Name "Documentation"
    Title   "Getting Started Guide"
    ShellExecute "http://developer.valvesoftware.com/wiki/Authoring_Tools/SDK_(CSGO)"
    Image   8
    Title   "Example Content"
    ShellExecute ".\\sdk_content"
    Image   13