<p>The description lost me a bit, what you should make sure is :</p>
<ul>
<li>Ensure the user ID and group ID inside the container match those on the host.</li>
<li>Make sure the permissions on the host directory allow the container to access it.</li>
<li>Use the --mount syntax instead of -v.</li>
</ul>
<pre><code>version: '3.8'
services:
  myservice:
    image: myimage
    user: 1000:1000
    volumes:
      - type: bind
        source: /etc/passwd
        target: /etc/passwd:ro
      - type: bind
        source: /mnt/e/test/my/files/location/on/host
        target: /app/my/files:rw

</code></pre>

CC BY-SA 4.0
2024-12-13T01:59:52.737Z
As per my post, user 1000 exists on the host (Windows) when I check via `wsl cat /etc/passwd`.  However, when I bind mount `/etc/passwd`, the file Docker is sourcing does not contain user 1000.  I have no idea where this `/etc/passwd` file is originating from, nor how to reference the `/etc/passwd` file that `wsl` uses..  This is the part that I want some answers for, not a different syntax to mounting the same file that does not contain user 1000.
John
CC BY-SA 4.0
2024-11-29T23:39:39.050Z
2024-11-29T23:39:39.050Z
YassineLbk
<p>I am running Docker Desktop for Windows with WSL2 integration.
I'm not sure what that wsl2 integration does though.</p>
<p>I am having trouble bind-mounting <code>/etc/passwd</code> from the host to the guest.</p>
<p>Docker compose looks like this:</p>
<pre><code>    user: 1000:1000
    volumes:
      - /etc/passwd:/etc/passwd:ro
      - /mnt/e/test/my/files/location/on/host:/app/my/files:rw
</code></pre>
<p>When I go into wsl and <code>cat /etc/passwd</code>, I can see there's a user <code>1000</code>.
However, when I start my docker container, it boot loops due to no access to <code>/app/my/files</code></p>
<p>So I tried this:</p>
<pre><code>    volumes:
      - /etc/passwd:/etc/passwd1:ro
      - /mnt/e/test/my/files/location/on/host:/app/my/files:rw
</code></pre>
<p>This starts the container as its running the app in admin instead of user 1000.
And then I ran:</p>
<pre><code>docker exec -it mycontainer cat /etc/passwd1
</code></pre>
<p>I can't see a user 1000 in that output, so I don't know where it's grabbing <code>/etc/passwd</code> on the host from.</p>
<p>How can I set a valid host (Windows) user to run my app?</p>

<docker><windows><security>
How to bindmount /etc/passwd using linux guest on windows host (docker desktop)?
John
# How to bindmount /etc/passwd using linux guest on windows host (docker desktop)?

(Asked by: username_0 on 2024-11-19)

I am running Docker Desktop for Windows with WSL2 integration.
I'm not sure what that wsl2 integration does though.
I am having trouble bind-mounting /etc/passwd from the host to the guest.
Docker compose looks like this:
    user: 1000:1000
    volumes:
      - /etc/passwd:/etc/passwd:ro
      - /mnt/e/test/my/files/location/on/host:/app/my/files:rw

When I go into wsl and cat /etc/passwd, I can see there's a user 1000.
However, when I start my docker container, it boot loops due to no access to /app/my/files
So I tried this:
    volumes:
      - /etc/passwd:/etc/passwd1:ro
      - /mnt/e/test/my/files/location/on/host:/app/my/files:rw

This starts the container as its running the app in admin instead of user 1000.
And then I ran:
docker exec -it mycontainer cat /etc/passwd1

I can't see a user 1000 in that output, so I don't know where it's grabbing /etc/passwd on the host from.
How can I set a valid host (Windows) user to run my app?

**Tags:** docker, windows, security


---

## 1 answers

### Answer by username_1 on 2024-11-29. Score: 0

The description lost me a bit, what you should make sure is :

Ensure the user ID and group ID inside the container match those on the host.
Make sure the permissions on the host directory allow the container to access it.
Use the --mount syntax instead of -v.

version: '3.8'
services:
  myservice:
    image: myimage
    user: 1000:1000
    volumes:
      - type: bind
        source: /etc/passwd
        target: /etc/passwd:ro
      - type: bind
        source: /mnt/e/test/my/files/location/on/host
        target: /app/my/files:rw

> **Comments:**
> **username_0**: As per my post, user 1000 exists on the host (Windows) when I check via `wsl cat /etc/passwd`.  However, when I bind mount `/etc/passwd`, the file Docker is sourcing does not contain user 1000.  I have no idea where this `/etc/passwd` file is originating from, nor how to reference the `/etc/passwd` file that `wsl` uses..  This is the part that I want some answers for, not a different syntax to mounting the same file that does not contain user 1000.  

---

