Accessing virtual com ports inside a WS2016 docker container - docker

Running on a Win7(host) and Virtual Box with Windows Server 2016 TP5(guest vm). On WS2016 i run docker, using the windowsservercore base image for the containers.
I'm trying out kind of a fleet management system where I try to fire up multiple simulated vehicles inside separate docker images.
These vehicle simulators uses a simulated gps which send data to a virtual com port, from which the simulated vehicles read.
In windows XP/7/Server 2016 I have successfully made use of com0com(2.2.2.0 signed) for creating the virtual com ports.
My problem is getting the virtual com ports installed inside a docker container, alternatively accessing them as devices on the host
My first attempt has been running com0com inside docker, installation of the drivers work fine using silent mode, but when creating virtual com port pairs using the installed application I run into problems. The command stalls and if I view the Application eventlog I can see a few rows of this kind for each time I try to run the command.
<date> <time> Information Windows Error Rep. .. 1001 Fault bucket , type 0
When instead trying to create the devices in the host and instead passing the devices I seem to fail to access them
Using com0com --list within the container I can see the devices but not with the same name as I in the host
In the associated Dockerfile I rename them using the com0com setupc.exe to the same name as identified on the host
The mode command issued on the host lists the ports properly, using the mode command from insde the container does on the other hand fail to list them, only showing one item: CON
I then tried passing them using the --device=//./COM128://./COM128 argument to docker run
NOTE!: Is this the correct "path" to the devices?
The noticable result of this is zero, the com0com setupc command gives the same result, same with mode
The strange thing is that when I run powershell and list the serialports i get the expected comports as available on the host, with the correct names, but trying to open one of them gives an exception
PS C:\sims\com0com> [System.IO.Ports.SerialPort]::getportnames()
COM128
COM129
PS C:\sims\com0com> $comports=[System.IO.Ports.SerialPort]::getportnames()
PS C:\sims\com0com> $port= new-Object System.IO.Ports.SerialPort $comports[0],9600,None,8,one
PS C:\sims\com0com> $port.open()
Exception calling "Open" with "0" argument(s): "The port 'COM128' does not exist."
Finally tried just about the same as above but with another virtual com port software(eltima), setting them up in the host, the final result when trying to open the port using ps in the container is the same as for the com0com configured ports
Update:
Tried a new approach, running the container in hyper-v instead, using the -isolation flag to docker run, given the thesis that you would be able to install the com0com drivers in a hyper-v container, not having to try to share them from the host.
Running in hyper-v forced us to change to running the nanoserver base image instead of the windowsservercore base image.
Currently stuck on not being able to run the com0com install tool in nanoserver since the installer(NSIS-based) is a 32bit application, nanoserver only able to run 64bit applications.
Quick glance indicates that a new version(3.0) of NSIS could be used along with the NSIS scripts included in the com0com repo.
All ideas on how to move forward are welcome!
P.S: Same question posted on msdn containers forum

Changed to using named pipes to get it to work since no one else seems to be using docker for windows with serial ports.

Related

Running Actinia on docker container

I have recently heard about Actinia and I would like to try it out (I am remote sensing anaylst, I am not used to use command line )
I use Windows 10 . I have cloned Actinia on github and trying to use it on my docker container. I changed my windows containers to linux containers. Once I type in on my GitBash
docker-compose build --pull
It stops at step 16/49, while trying to connect to GRASS GIS. It iterates on the same problem,
GRASS GIS libgis version and date number not available
ERROR: Cannot open URL:
and the url he is trying to connect to.
Thus, I wonder if there is a configuration I am missing.
Source: https://github.com/mundialis/actinia_core/tree/master/docker

How to reduce default VM memory for Docker Linux containers on Windows

Scenario
Windows 10 Professional
Docker 18.06.1-ce running in Windows container mode
4GB of available memory on host system
using Hyper-V virtual machine
Problem
When trying to "switch to Linux containers" via Docker's taskbar item the process fails after a couple of seconds showing an error about "Not enough memory to start Docker".
Since the host system does not have that much memory, I'd like to reduce the maximum amount of memory the global Docker machine is allowed to use (I think 2 GB is the default here). Thus, I'd like to reduce that to just 1 GB.
When having Docker running in Windows container mode, there is no "advanced" section in Docker's settings that would allow to reduct that memory assignment easily.
I was able to find the "MobyLinuxVM" using Windows' Hyper-V manager. However, when adjusting memory settings there, it is overwritten each time I start Docker and try again switching to Linux container mode.
Question
Is there a different way to define the maximum amount of memory for Docker without using the user interface (which won't work in this scenario due to the missing "advanced" section in Windows container mode - before being able to switch to Linux containers)?
After some searching I found out that settings of Docker's user interface are stored in %APPDATA%\Docker\settings.json (e.g. C:\Users\olly\AppData\Roaming\Docker), memory settings are defined in memoryMiB property.
The following solved the problem on my environement:
quit Docker
modify settings.json file using notepad %APPDATA%\Docker\settings.json in the run command prompt (Windows-Key + R)
adjust value memoryMiB to 1024 (has been 2048 before)
in Docker versions 19.x and later the property is called memoryMiB
in Docker versions 18.x and before the property was called VmMemory
save settings.json
start Docker and finally being able to use "switch to Linux containers"
Property memoryMiB in Docker versions 19.x and later
Property VmMemory in Docker versions 18.x and before

Start Docker silently on Windows 10

I have installed Docker Edge 18.06.01-ce on Microsoft Windows 10 with Fall Creators Update.
I want to find a way to configure Docker silently - from for example command console. Unfortunately, I can't use Docker features without Docker daemon running in the background.
Normally I would open Docker for Windows.exe- it does manage Hyper-V machine MobyLinuxVM, creates network switches etc. The problem is that this application is running in tray and has GUI.
Is there any way to start this application from command console and wait until it will configure everyting (until Docker will work correctly)? I have already tried creating manually new machine and starting Docker service, but it does not work - I suspect that I need to map new machine somehow to new console windows (docker-machine env?).

Attach a debugger to an application inside docker

Docker is a wonderful tool for running/deploying your application in a well-defined, controlled environment, and is well supported by e.g. the GitLab CI or by MS Azure.
We would like to use it also in the development phase, so that all developers have the same environment available. Of course, we want to keep the image as light as possible and we do not want e.g. any IDE or other development tool inside of it.
So the actual development takes place outside of docker.
Running our (python) application inside of docker is no problem, but debugging it is not trivial: I do not know of a way to attach a debugger to an application running inside docker. In theory this should be possible, but how does one do it?
Additional info: we use visual studio code, that does have some docker, plugin, but nothing of this sort is mentioned.
Turns out that this is possible, following the same steps needed for remote debugging.
The IP address of the docker image can be retrieved through:
docker inspect <container_id> | grep -i ip
just be sure to add at the beginning of your application:
import ptvsd
# Allow other computers to attach to ptvsd at this IP address and port, using the secret
ptvsd.enable_attach(secret=None, address = ('0.0.0.0', 3000))
ptvsd.wait_for_attach()
'0.0.0.0' means on all interfaces.
For vscode, the last steps consists in adapting the python: Attach configuration, specifying the address and the remote and local roots for your script.
However, for some mysterious reason my breakpoints are ignored.

Windows 10 Docker Network DNS doesn't work after reboot

I'm not sure if this is an issue with the current version of Windows Docker network or poor configuration and misunderstanding on my part, but I have the following setup:
2 Docker containers (built using the Microsoft/ASP.NET image as a base) running a .NET MVC application in each.
1 Docker container running SQL server (built using the Microsoft/mssql-server-windows image)
When I create all 3 containers everything works great, I can attach and ping all other the other containers using their names without any issue. The applications run and can communicate with each other as I hoped.
However, when I reboot my machine and start all the containers again they can no longer ping/communicate with each other using their names (using IP addresses is fine).
I've tried this on the default NAT network and also tried replacing the NAT network with my own custom NAT network.
To resolve the issue I have to run the force network disconnect command for each container as such:
docker network disconnect nat <containername> --force
And then I have to reconnect each container to the network before starting them up. All containers can then ping/communicate with each other using their names as well as their IP addresses.
FYI, this is a development environment but I was hoping to do something similar in Azure using a Windows Server 2016 VM, although I don't quite know what the best network configuration is for live production yet as I need to have multiple applications (in separate containers) on the same node accessed via their own subdomains.
Any help or guidance would be great.
I'm not sure, in part because this question was asked several months before any other example I've run into, but this sounds very similar to the problem described at https://github.com/docker/for-win/issues/1038.
Basically, there appears to be a problem introduced with the 1709 update to Windows 10 which results in a scenario where Hyper-V networking doesn't work the way it ought to.
There appear to be two common ways of working around this problem: Turning off "Fast Start" in the Control Panel => Power Options => System Settings, or restarting Docker for Windows and any containers after booting. I also thought I saw something on a Microsoft blog post indicating that the underlying problem has now been resolved and will be included in an update to Windows 10, but alas I can no longer find that information or the specific version number in which the problem was (theoretically) resolved. It may well be the delayed 1803 "Spring Creators Update" release.

Resources