Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial port unavailable under Windows even with --privileged flag #1018

Open
remyleone opened this issue Aug 18, 2017 · 57 comments
Open

Serial port unavailable under Windows even with --privileged flag #1018

remyleone opened this issue Aug 18, 2017 · 57 comments

Comments

@remyleone
Copy link

Description

I got a device that talk over serial port. On Unix it shows up as a /dev/ttyUSB0, on Windows as a COM.
I would like to be able to talk to this serial device from a container running on top of Docker for Windows.

Steps to reproduce the issue:

  1. Connect something that talk over a USB serial port to your Windows machine
  2. docker run -it --privileged ubuntu ls /dev

Describe the results you received:

  • There is no ttyUSB0

Describe the results you expected:

There should be a ttyUSB0 showing up

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      17.06.0-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:30:30 2017
 OS/Arch:      windows/amd64

Server:
 Version:      17.06.0-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   02c1d87
 Built:        Fri Jun 23 21:51:55 2017
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

Containers: 6
 Running: 0
 Paused: 0
 Stopped: 6
Images: 3
Server Version: 17.06.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.36-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 973.8MiB
Name: moby
ID: TMWG:M7LS:5PG2:EZ4E:37KI:UGHT:OJIR:AVKU:V42E:GVNL:2GR4:QNJW
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 15
 Goroutines: 25
 System Time: 2017-08-18T09:09:52.1702444Z
 EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

@friism
Copy link

friism commented Aug 18, 2017

Thanks for opening this issue for tracking this feature request. We've had a few similar requests for USB device support. Currently this is not a design use-case for Docker for Windows.

You might be able to achieve what you want by setting up a separate hyper-v (or virtualbox) VM and installing Docker in that. That would give you more freedom to use hyper-v features like attaching special host-hardware and using it with Docker Linux containers.

You can even use Docker Machine to automate part of this process: https://docs.docker.com/machine/drivers/hyper-v/

@plagov
Copy link

plagov commented Nov 17, 2017

Does this issue still persist? I'm also looking for a way to connect serial devices to containers in Docker for Windows.
@sieben did you find any working option for your use-case?

@remyleone
Copy link
Author

remyleone commented Nov 18, 2017 via email

@adrianpanicek
Copy link

I would also love to have serial ports implemented in Docker For Windows.

@nistath
Copy link

nistath commented Dec 7, 2017

There is high demand from people that want to use Docker for cross platform embedded toolchain environments. Maybe the Docker team should reconsider...

@stevebus
Copy link

I would definitely love to see this implemented. It will be a much more common request since Azure IoT Edge leverages docker containers for modules -> http:https://docs.microsoft.com/en-us/azure/iot-edge

@Moshik177
Copy link

Does this issue still persist? this issue is highly demanded by a lot of people

@rn
Copy link
Contributor

rn commented Feb 1, 2018

Hyper-V does not seem to allow passing through local USB devices to a VM so we can't expose serial USB device or similar to the VM running linux containers

@guddu2112
Copy link

Any update on this issue? is it supported now? i was exploring for similar results on windows host.

@appcodr
Copy link

appcodr commented Feb 20, 2018

This feature is highly desired to use with Azure IoT Edge. Is this going to be implemented soon?

@michaelosthege
Copy link

I'd be very interested in this feature as well. (Need to talk to COM-ports from Docker containers..)

@lenz45
Copy link

lenz45 commented Jul 23, 2018

Hi folks,

My team is interested in learning more about the needs discussed in this thread and to better understand what outcomes you are trying to enable. We'd be interested in hearing your responses to the following questions:

  • What scenarios are you targeting?
  • Are the scenarios primarily for IoT enterprise solutions?
  • What type of devices are you interfacing with that require serial or USB access (specific examples would be great)?
  • Is there any workaround or interim solution that might solve your needs in the absence of access from containers?
  • Are you looking to use Win32 APIs (CreateFile, ReadFile, WriteFile, DeviceIoControl, etc.) or some other APIs to access these devices?
  • Can you identify which APIs would be required to meet your needs?

Thanks in advance for any details you can provide to help us better understand how your needs could be met.

@adrianpanicek
Copy link

@lenz45

  • I'm trying to run ESP-IDF on my Windows maching without using MINGW32.
  • My use is primary for the IoT
  • ESP32 Devboard-C
  • Current workaround is using MinGW
  • No I don't need to use Win32 API

@lkishfy
Copy link

lkishfy commented Jul 24, 2018

@lenz45

  • Attempting to use an encoder that talks over serial to a Node application. Won't be able to use Docker without this feature. We use physical computing with node.js a lot, so having support for serial with Docker would be really helpful.
  • Not primarily IoT
  • Rotary Encoder from RLS
  • Having trouble finding a workaround
  • No
  • Don't necessarily need an API

@nistath
Copy link

nistath commented Jul 24, 2018

@lenz45

  • We want to standardize our embedded flashing toolchain. All we need to be able to do is map Windows COM ports to /dev/ttyUSBxx devices inside the Docker container. Our Dockerfile works on Linux.
  • It's not IoT but it is embedded programming.
  • ST-LINK/V2 and FTDI FT232RL chips.
  • We currently use the Windows Subsystem for Linux which can map serial ports.
    An inconvenience is that /dev/ttyS1 through 100 are predefined and you need to run mode.com on Windows to find what COM ports are defined (say COM7) and then connect to /dev/ttyS7 on the WSL side.
  • No. We just need a mapping for serial ports.

@stevebus
Copy link

What scenarios are you targeting?

Azure IOT Edge scenarios that talk to hardware...

Are the scenarios primarily for IoT enterprise solutions?

yes

What type of devices are you interfacing with that require serial or USB access (specific examples would be great)?

industrial machines that talk over RS232; Modbus over serial; GPIO/I2C/SPI-based sensors

Is there any workaround or interim solution that might solve your needs in the absence of access from containers?

Nope

Are you looking to use Win32 APIs (CreateFile, ReadFile, WriteFile, DeviceIoControl, etc.) or some other APIs to access these devices?

System.IO.Ports for C#; pyserial for python; serialport for node, etc...

Can you identify which APIs would be required to meet your needs?

@lenz45
Copy link

lenz45 commented Aug 13, 2018

Thanks for the responses you provided and apologies for not getting back to this thread sooner. I was waiting for a blog post to go live that explains some work Microsoft is doing in this area. Please take a look at the post here and feel free to provide feedback directly on the TechNet site: https://blogs.technet.microsoft.com/virtualization/2018/08/13/bringing-device-support-to-windows-server-containers/

@dominikbenner
Copy link

@lenz45
But this works only for windows container on windows host.

Is it possible to use a com device insinde a linux container on a windows host??

@lenz45
Copy link

lenz45 commented Aug 28, 2018

@s4ndst0rm
You are correct that this work pertains strictly to Windows containers on Windows. As of today, you cannot access a COM device (or any other host device) from a Linux container running on Windows. However, all feedback we can gather around this scenario would be helpful in guiding us.

@aazavid
Copy link

aazavid commented Nov 13, 2018

All we need to be able to do is map Windows COM ports to /dev/ttyUSBxx devices inside the Docker container. Our Dockerfile works on Linux.
It's IoT embedded programming.
ST-LINK/V2
While not decide
No. We just need a mapping for serial ports.

@rgwa69
Copy link

rgwa69 commented Nov 20, 2018

We also need access to an RS232 interface from Linux Docker running on a Windows host.
This means map a Windows COM port to a /devttySx device.

@Chanoian
Copy link

@lenz45
I'm trying to flash esp-idf from a Linux docker runs under windows 10.
I don't want to use Mingw32.

@karthikshanmugam
Copy link

karthikshanmugam commented Dec 12, 2018

@lenz45

Embedded device build, flash and test
yes
Embedded boards that talk over Serial Port
Nope
Nope

@Geoff-Field
Copy link

Geoff-Field commented Jan 9, 2019

For the sake of a "me too":

  • What scenarios are you targeting?
    Embedded development on ESP32-based devices (WiFi modules)

  • Are the scenarios primarily for IoT enterprise solutions?
    Yes

  • What type of devices are you interfacing with that require serial or USB access (specific examples would be great)?
    uBlox Nina EVK board (ESP32-based WiFi module), using an FTDI-based USB-serial converter

  • Is there any workaround or interim solution that might solve your needs in the absence of access from containers?
    Possibly a means of getting the ESP32 code to actually compile under Windows.

  • Are you looking to use Win32 APIs (CreateFile, ReadFile, WriteFile, DeviceIoControl, etc.) or some other APIs to access these devices?
    No

  • Can you identify which APIs would be required to meet your needs?
    No. All we want is to talk to the USB COM port.

@anilsamuel
Copy link

  1. What scenarios are you targeting?
    We have serial medical devices for which we develop integration solutions. This feature would benefit us for our docker based dev environment.
  2. Are the scenarios primarily for IoT enterprise solutions?
    IoT is also in scope.
  3. What type of devices are you interfacing with that require serial or USB access (specific examples would be great)?
    https://datainnovations.com/jresultnet is a middleware we currently use for interfacing with the medical devices. few such medical devices are https://www.beckmancoulter.com/en/products/hematology/dxh-800, http:https://www.immucor.com/global/Products/Pages/Neo.aspx, https://www.transfusion.abbott/int/en/offerings/brands/prism/prism-next
  4. Is there any workaround or interim solution that might solve your needs in the absence of access from containers?
    Virtualbox
  5. Are you looking to use Win32 APIs (CreateFile, ReadFile, WriteFile, DeviceIoControl, etc.) or some other APIs to access these devices?
    No
  6. Can you identify which APIs would be required to meet your needs?
    We be using Java API libraries such as jSerialComm.

@HeisenbergK
Copy link

It seems this is a very much requested feature for Docker Developers to ignore.
In my case I have a piece of hardware developed from one lab that provides me with controllers and the driver is written only for Linux. My organization though has an infrastructure based on Windows. So my idea was to use the existing driver of the controller in a Linux container and only develop a handler software to run in it, instead of having to code the entire drivers for windows.

@liydu
Copy link

liydu commented Nov 12, 2019

Up for this and for macOS: docker/for-mac#900

@kjeldflarup
Copy link

kjeldflarup commented Jan 20, 2020

I had hopes that I could use docker to distribute some bootstrap procedures for hardware boards, but unfortunately not this time. I hope that this will be possible some time soon.

@jordanmelnychukhendrickson

Has Microsoft showed any interest in supporting hardware bridging from a Windows host into a container? I saw they supported Linux hosts to Windows containers. This would be huge for us because it would cut back on the headache of sharing some of our embedded test/diagnostic software and configs between different machines.

@ntindle
Copy link

ntindle commented Feb 19, 2020

Is there windows in windows support for this? I read through the thread and it mostly seemed to be questions for Linux in Windows

@stevebus
Copy link

yes, windows in windows does give you some hardware access. (https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/hardware-devices-in-containers)

@mmusil25
Copy link

mmusil25 commented Feb 28, 2020

I think everyone in this thread faces the same issue that we had hoped docker would solve:

How do I consistently deploy a program on any environment which requires access to embedded system peripherals?

On linux, docker solved a lot of problems I was having with machine-specific compatibility issues which made deployment a pain. I would be a raving fan if the same could be said for windows and mac.

What scenarios are you targeting?
Distribution of hardware testing programs which require embedded systems for inputs/outputs.

Are the scenarios primarily for IoT enterprise solutions?
Yes

What type of devices are you interfacing with that require serial or USB access (specific examples would be great)?
FT232H serial to USB and SDI-12 to USB.

Is there any workaround or interim solution that might solve your needs in the absence of access from containers?

I will need to give up the standardization of a docker container and ensure that each machine can run the software manually.

Are you looking to use Win32 APIs (CreateFile, ReadFile, WriteFile, DeviceIoControl, etc.) or some other APIs to access these devices?
No

Can you identify which APIs would be required to meet your needs?

Just need simple way to get a linux container to access com ports on a windows host.

Thanks

@epicabsol
Copy link

  • What scenarios are you targeting?
    2-way serial Arduino communication with ROS
  • Are the scenarios primarily for IoT enterprise solutions?
    Not enterprise, no internet. So I guess just a 'thing'.
  • What type of devices are you interfacing with that require serial or USB access (specific examples would be great)?
    Most Arduino boards?
  • Is there any workaround or interim solution that might solve your needs in the absence of access from containers?
    Well if there was I wouldn't be here...
  • Are you looking to use Win32 APIs (CreateFile, ReadFile, WriteFile, DeviceIoControl, etc.) or some other APIs to access these devices?
    I just want to use the standard Linux Arduino setup, no idea what API it uses
  • Can you identify which APIs would be required to meet your needs?
    Access to COM ports from inside the container.

@gkgeorgiev
Copy link

gkgeorgiev commented Oct 11, 2020

In my case I have Win 10, with Zigbee USB stick (serial COM) and Home Assistant running as a docker container based on Linux image.

@masoudr
Copy link

masoudr commented Oct 25, 2020

I'm having the same issue, but is there any other way or an alternative? This issue could potentially prevent me from using Docker with my project.

@johngai19
Copy link

I'd be very interested in this feature as well. (Need to talk to COM-ports from Docker containers..)

@Manish5432
Copy link

is anybody have idea - connecting docker container with COM2 port?
docker is installed on my windows machine.

@kjeldflarup
Copy link

@Manish5432 Just a workaround, try with a network COM port forwarder.

@Manish5432
Copy link

@Manish5432 Just a workaround, try with a network COM port forwarder.

Can you give me some sample url or guide me how i can do with network COM port forwarder.

@kjeldflarup
Copy link

It has been a while since I used this technique. And back then I mapped a USB port on a Raspberry Pi to Linux.
Try searching for networked USB ports on Google.

@JosuGZ
Copy link

JosuGZ commented Jul 1, 2021

Aparently it is posible to access serial ports on WSL: https://icircuit.net/accessing-com-port-from-wsl/2704

Is it still impossible to do this on Docker?

EDIT: Argh, I guess this is the problem: microsoft/WSL#4322

@louking
Copy link

louking commented Aug 2, 2023

Seems like "me, too" isn't going to help me -- my need is now. This stinks. I was halfway into my project and now need to recalibrate to do it without docker I guess.

@gkgeorgiev
Copy link

Seems like "me, too" isn't going to help me -- my need is now. This stinks. I was halfway into my project and now need to recalibrate to do it without docker I guess.

I switched to native Linux. In fact that made me optimize my solution so i don't install Hassio anymore and I don't regret it much.

@louking
Copy link

louking commented Aug 2, 2023

Seems like "me, too" isn't going to help me -- my need is now. This stinks. I was halfway into my project and now need to recalibrate to do it without docker I guess.

I switched to native Linux. In fact that made me optimize my solution so i don't install Hassio anymore and I don't regret it much.

I am trying to interface a serial device via csv file to a COTS windows based program. I think I need to try to run a windows container for my app (a la https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/hardware-devices-in-containers) and linux containers for the database, web server, etc.

UPDATE: From https://hub.docker.com/_/microsoft-windows, "Windows requires the host OS version to match the container OS version.", which doesn't exactly meet what I'm trying to achieve. Maybe I'll bolt on a serial device reader process outside of the docker environment, to feed a linux container with the serial device outputs. Bleh.

@chintanp
Copy link

This feature would be really nice to have.

@rlneumiller
Copy link

rlneumiller commented Jul 19, 2024

I haven't seen any mention of usbipd in this thread, so here it is. I use usbipb on Windows 11 to bind and attach COM ports on Windows 11 to docker containers (ttyACM0, etc) that I use for building and flashing embedded devices. The important bit is adding --device /dev/ttyACM0, or whatever tty shows up in a wsl2 shell, to your docker run command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests