Accessing virtual com ports from inside a docker windowsservercore container RRS feed

  • Question

  • Hi

    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 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 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()
    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> $
    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, 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

    All ideas on how to move forward are welcome!


    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. 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.


    • Edited by Thursday, September 29, 2016 2:40 PM Updated information
    Tuesday, September 27, 2016 8:33 AM

All replies

  • Have you perhaps found a solution to this issue? I landed up at the same end trying to get a COM Port translation into a windows docker container. Would be really interested to hear if that worked out for you.
    Thursday, September 28, 2017 8:45 PM
  • Hey there Kristofer,

    The Docker --device argument doesn't actually do anything on Windows. I'll take a note to ping Docker to update the docker tool to spit out an error, instead of pretending it works. Processes inside Windows Containers cannot access COM ports on the host.

    Can you share more information on the vehicles? Can you configure them to read from anything other than a COM port? Is this something I can inspect?

    There may be some hacks we can come up with to bridge into the host to access your COM port. I'll need to think about this overnight, standby.

    Thursday, October 5, 2017 7:37 AM
  • Hi Rafael,

    thank you for the clarification, I've been skimming forums for weeks in order to get an idea whether that works or not.
    I've been trying to access a ZWave dongle on a windows host from inside a docker container for home automatio purposes. Currently, I've been spending some time trying to tunnel an external device inside a docker container over LAN using
    - usbip ( or  - more flexibly -

    - virtualhere (

    In that scenario, the physical COM device would be attached to a raspberry pi (usbip) or the windows host directly (virtualhere). The host running on that system would provide the devices to the client running inside the docker container. 
    That part seems to work quite well so far, the client can reach the host device and attach to it. But I don't seem to be able to also access the virtual devices in the container - same error about accessing COM ports. I'd be quite interested in any idea out there to tunnel usb devices into windows hosted containers!

    Wednesday, October 18, 2017 6:50 PM
  • Will update this thread tonight, I think I have a quick hack for you (you'll lose container portability as a side effect). Going to test it with some COM equipment to verify. Thanks for your patience!
    Monday, October 23, 2017 11:05 PM
  • Tuesday, October 24, 2017 10:57 PM
  • VERY interesting, thank you so much for putting this out here! I'll try my luck as soon as I can.
    Sunday, November 26, 2017 10:09 PM