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

Bind mount docker.sock with Windows container #6813

Closed
1 of 2 tasks
masoudr opened this issue May 20, 2020 · 6 comments
Closed
1 of 2 tasks

Bind mount docker.sock with Windows container #6813

masoudr opened this issue May 20, 2020 · 6 comments

Comments

@masoudr
Copy link

masoudr commented May 20, 2020

  • I have tried with the latest version of my channel (Stable or Edge)
  • I have uploaded Diagnostics
  • Diagnostics ID:

Expected behavior

The service should set up without any problem.

Actual behavior

I get this error:

ERROR: for webservice  Cannot create container for service webservice: invalid volume specification: '//var/run/docker.sock:/var/run/docker.sock:rw'
ERROR: Encountered errors while bringing up the project.

Information

  • Windows Version: Win10 1909 X64
  • Docker Desktop Version: 2.2.0.3
  • Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No

I'm trying to mix Windows and Linux containers and as you might know, the latest version that it works properly is 2.2.0.3 (based on this issue). My problem is with the mounting docker.sock into Linux container which seems syntactically right. I tested this with Linux containers and I'm not sure about how to set when using Windows containers.

Steps to reproduce the behavior

I set the experimental feature in my docker daemon and Windows container selected.
Here is my daemon config:

{
  "registry-mirrors": [],
  "insecure-registries": [],
  "debug": true,
  "experimental": true,
  "graph": "E:\\Docker"
}

Here is my sample docker-compose.yml:

version: '2.4'

services:
  webservice:
    platform: linux
    build:
      context: ./app/webservice
    ports:
      - "443:443"
    volumes:
      - //var/run/docker.sock:/var/run/docker.sock
      - ./app/webservice:/app

And the Dockerfile:

FROM python:3.8
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt
RUN mkdir /app
RUN mkdir /build
COPY ./app /app
WORKDIR /app
@masoudr masoudr changed the title Mount docker.sock in windows container Bind mount docker.sock with Windows container May 20, 2020
@rirlswift
Copy link

rirlswift commented May 22, 2020

Seeing a similar issue with a different use case.

from container run container that has bind mounts to docker socket (docker build from docker container: CI use case).

Windows: must use sudo from the container running from host container.
Linux: container (host) and build container share identical docker group id (gid) -- no sudo; otherwise sudo required.

Linux: everything can use the same docker group gid (identical numeric value).
Windows: docker_users (on host); how to map to docker group in unix container?

@rirlswift
Copy link

I think based on here that these use cases require using a TCP socket (eg., must remote from local)

This might require TLS?

@masoudr
Copy link
Author

masoudr commented May 22, 2020

@rirlswift Thanks for the info but how can I bind the TCP socket I mean I tried but I got this error:

version: '2.4'

services:
  webservice:
    platform: linux
    build:
      context: ./app/webservice
    ports:
      - "443:443"
    volumes:
      - type: npipe
        source: ////./pipe/docker_engine
        target: /var/run/docker.sock
        consistency: delegated

ERROR: for webservice Cannot create container for service webservice: invalid mount config for type "npipe": Linux containers on Windows do not support named pipe mounts

Also the doc said it has a TCP like tcp://localhost:2375 but how can I access this address in my webservice container?
I can use the network_mode and connect to the host network for the TCP above. But I would disconnect from other networks and so my webservice will lose the connection to other services right?

@fsproru
Copy link

fsproru commented May 23, 2020

@masoudr, did you try using DOCKER_HOST=‘tcp://0.0.0.0:2375’ docker version inside the Linux container?

Having a similar issue trying to mount and named pipe into a Linux container from a Windows host. Wondering if proxying a port and using DOCKER_HOST environment variable inside the container will work better.

@docker-robott
Copy link
Collaborator

Issues go stale after 90 days of inactivity.
Mark the issue as fresh with /remove-lifecycle stale comment.
Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle stale

@docker-robott
Copy link
Collaborator

Closed issues are locked after 30 days of inactivity.
This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows.
/lifecycle locked

@docker docker locked and limited conversation to collaborators Oct 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants