louislam / dockge

A fancy, easy-to-use and reactive self-hosted docker compose.yaml stack-oriented manager
https://dockge.kuma.pet
MIT License
12.84k stars 366 forks source link

The volume stacks is lost on the Windows #72

Open aliuq opened 11 months ago

aliuq commented 11 months ago

I deployed dockge on Windows at D:\myCompose\dockge and my docker-ompose.yaml file looks like this:

version: "3.8"
services:
  dockge:
    image: louislam/dockge:1
    restart: unless-stopped
    ports:
      # Host Port:Container Port
      - 5001:5001
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/app/data

      # If you want to use private registries, you need to share the auth file with Dockge:
      # - /root/.docker/:/root/.docker

      # Your stacks directory in the host (The paths inside container must be the same as the host)
      # ⚠️⚠️ If you did it wrong, your data could end up be written into a wrong path.
      # ✔️✔️✔️✔️ CORRECT EXAMPLE: - /my-stacks:/my-stacks (Both paths match)
      # ❌❌❌❌ WRONG EXAMPLE: - /docker:/my-stacks (Both paths do not match)
      - ./stacks:/stacks
    environment:
      # Tell Dockge where is your stacks directory
      - DOCKGE_STACKS_DIR=/stacks

I tried deploying uptime-kuma, which has the following compose.yaml:

version: "3.8"
services:
  uptime-kuma:
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
      - ./data:/app/data
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 13001:3001 # <Host Port>:<Container Port>
    restart: always

Now the problem is that I don't know how to specify the stack's directory, if I follow my previous binding ./stacks, then I can get D:\myCompose\dockge\stacks\uptime-kuma\compose.yaml, but I don't know where the ./data bound in compose.yaml is.

If you use the absolute path D:\myCompose\dockge\stacks, I get another error

Error response from daemon: invalid volume specification: '/run/desktop/mnt/host/d/myCompose/dockge/stacks:stacks:rw': invalid mount config for type "bind": invalid mount path: 'stacks' mount path must be absolute
louislam commented 11 months ago

Yes, because of the path mapping issue on Windows, I would say currently Dockge's container is not supported on Windows.

I will add non-Docker method later for Windows.

aliuq commented 11 months ago

Thanks for the reply.

AmIBeingObtuse commented 11 months ago

Hi

I run Dockge on docker desktop on windows 10 pro. I don't have any issues with mapping. Here is my compose file and converted run command that I use:

version: "3.8"
services:
  dockge:
    image: louislam/dockge:latest
    restart: unless-stopped
    ports:
      # Host Port:Container Port
      - "5032:5001"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "C:\Yourpath\Data:/app/data"
      # If you want to use private registries, you need to share the auth file with Dockge:
      # - /root/.docker:/root/.docker
      # Your stacks directory in the host (The paths inside container must be the same as the host)
      # ⚠️⚠️ If you did it wrong, your data could end up be written into a wrong path.
      # ✔️✔️✔️✔️ CORRECT EXAMPLE: - /my-stacks:/my-stacks (Both paths match)
      # ❌❌❌❌ WRONG EXAMPLE: - /docker:/my-stacks (Both paths do not match)
      - "C:\Yourpath\Stacks:/opt/stacks"
    environment:
      # Tell Dockge where is your stacks directory
      - `"DOCKGE_STACKS_DIR=/opt/stacks"`

Docker run command:

docker run -d `
  --name dockge `
  -p 5032:5001 `
  --restart unless-stopped `
  -v /var/run/docker.sock:/var/run/docker.sock `
  -v C:\Yourpath\Data:/app/data `
  -v C:\Yourpath\Stacks:/opt/stacks `
  -e DOCKGE_STACKS_DIR=/opt/stacks `
  louislam/dockge:latest

This stores my stacks in C:\Yourpath\Stacks\StackName\compose.yaml

Docker prompted me to confirm I was happy sharing the directory. If that doesn't happen for you, go into docker dekstop settings and resources to ensure the directory is listed as shared. I am also using hyper v not WSL.

Let me know if this helped. I'm assuming your using docker desktop on windows.

aliuq commented 11 months ago

@AmIBeingObtuse Thanks your reply, can u try to add the belows compose.yaml to check the uptime-kuma data stored position?

version: "3.8"
services:
  uptime-kuma:
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
      - ./data:/app/data
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 13001:3001 # <Host Port>:<Container Port>
    restart: always

I also will try to use C: to store all stacks and data at tonight

AmIBeingObtuse commented 11 months ago

@AmIBeingObtuse Thanks your reply, can u try to add the belows compose.yaml to check the uptime-kuma data stored position?

version: "3.8"
services:
  uptime-kuma:
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
      - ./data:/app/data
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 13001:3001 # <Host Port>:<Container Port>
    restart: always

I also will try to use C: to store all stacks and data at tonight

Because I have mapped my paths in my compose as:

- "C:\Yourpath\Stacks:/opt/stacks"

and left the environmental variable as:

- `"DOCKGE_STACKS_DIR=/opt/stacks"`

Your compose file gets stored in:

- "C:\Yourpath\Stacks\UptimeKuma\compose.yaml"

for me.

I had to change your compose file to:

version: "3.8"
services:
  uptime-kuma:
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
      - C:\Yourpath\Uptimekuma:/app/data
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 13001:3001 # <Host Port>:<Container Port>
    restart: always

So I can persist the data and make it easier to access the files. But it did work fine via Dockge.

louislam commented 11 months ago

C:\Yourpath\Uptimekuma:/app/data

Yes, you are right. As long as it is a absolute path, it is ok to use, but I assume that most people will not aware this, so I claimed that Dockge is not supported on Windows at the moment.

AmIBeingObtuse commented 11 months ago

Surely its a standard mapping?

I don't think it needs any change at all. As long as the volume is mapped as shown it works fine. That doesn't mean its not windows supported.

Maybe just provide a note in the default compose file for example:

version: "3.8"
services:
  dockge:
    image: louislam/dockge:1
    restart: unless-stopped
    ports:
      # Host Port : Container Port
      - 5001:5001
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./data:/app/data #Example On Windows you can map the volume as - C:\Yourpath\Dockge\Data:/app/data

      # If you want to use private registries, you need to share the auth file with Dockge:
      # - /root/.docker/:/root/.docker

      # Your stacks directory in the host (The paths inside container must be the same as the host)
      # ⚠️⚠️ If you did it wrong, your data could end up be written into a wrong path.
      # ✔️✔️✔️✔️ CORRECT: - /my-stacks:/my-stacks (Both paths match)
      # ❌❌❌❌ WRONG: - /docker:/my-stacks (Both paths do not match)
      - /opt/stacks:/opt/stacks #Example on windows you can map the volume as - C:\Yourpath\Dockge\Stacks:/opt/stacks
    environment:
      # Tell Dockge where is your stacks directory (If using windows keep this the same and see above for volume mapping).
      - DOCKGE_STACKS_DIR=/opt/stacks

IMO

aliuq commented 11 months ago

I have a another question, if I used absolute path on dockge volumes

volumes:
  - "/var/run/docker.sock:/var/run/docker.sock"
  - "C:/Yourpath/Data:/app/data"
  - "C:/Yourpath/Stacks:/opt/stacks"
environment:
  - `"DOCKGE_STACKS_DIR=/opt/stacks"`

Need I use absolute path on all stacks volume which mapped data? e.g.

version: "3.8"
services:
  uptime-kuma:
    image: louislam/uptime-kuma:1
    container_name: uptime-kuma
    volumes:
-     - ./data:/app/data
+     - C:/Yourpath/Uptimekuma:/app/data
      - /var/run/docker.sock:/var/run/docker.sock:ro
    ports:
      - 13001:3001 # <Host Port>:<Container Port>
    restart: always

If uptime-kuma always need absolute path to bind mount /app/data, may dockge volumes use relative path instead of absolute path?

AmIBeingObtuse commented 11 months ago

Hi

I do use absolute paths as you've described.

I don't see any reason not to when using docker desktop on windows and in compose files/stacks.

It hasn't failed me yet.

That said I know some images have issues with this like a postgres container which requires a volume in docker when used on windows.

So I would map a volume for that like

Volumes:
 - imagenamepostgres:/var/lib/postgresql/data

So it depends. Welcome to the world of learning docker and self hosting. I'm still in the learning phase myself. 👌

On Fri, 24 Nov 2023, 05:31 AliuQ, @.***> wrote:

I have a another question, if I used absolute path on dockge volumes

volumes:

  • "/var/run/docker.sock:/var/run/docker.sock"
  • "C:/Yourpath/Data:/app/data"
  • "C:/Yourpath/Stacks:/opt/stacks"environment:
  • "DOCKGE_STACKS_DIR=/opt/stacks"

Need I use absolute path on all stacks volume which mapped data? e.g.

version: "3.8" services: uptime-kuma: image: louislam/uptime-kuma:1 container_name: uptime-kuma volumes:- - ./data:/app/data+ - C:/Yourpath/Uptimekuma:/app/data

  • /var/run/docker.sock:/var/run/docker.sock:ro ports:
  • 13001:3001 # : restart: always

If uptime-kuma always need absolute path to bind mount /app/data, may dockge volumes use relative path instead of absolute path?

— Reply to this email directly, view it on GitHub https://github.com/louislam/dockge/issues/72#issuecomment-1825167968, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2PH7LJNTZPMMOCCJMJFQU3YGAWJ7AVCNFSM6AAAAAA7R3UYISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRVGE3DOOJWHA . You are receiving this because you were mentioned.Message ID: @.***>

holocronology commented 10 months ago

Should this:

 image: louislam/dockge:1

be this?

 image: louislam/dockge:latest
AmIBeingObtuse commented 10 months ago

Should this:

 image: louislam/dockge:1

be this?

 image: louislam/dockge:latest

Yes should be latest.

This install video for Dockge on windows really helped me

https://youtu.be/lEwEgR-nja4?si=OyuGy_M_gWP-Ywww

holocronology commented 10 months ago

I agree @AmIBeingObtuse.

@louislam I think the compose.yaml and other documentation should be updated to reflect this.

louislam commented 10 months ago

No, using 1 is the best.

1 is pointing the latest version of v1.

latest is a bad practice for most images:

https://stackoverflow.com/questions/72889955/is-it-bad-practice-to-use-mysqllatest-as-docker-image

AmIBeingObtuse commented 10 months ago

No, using 1 is the best.

1 is pointing the latest version of v1.

latest is a bad practice for most images:

https://stackoverflow.com/questions/72889955/is-it-bad-practice-to-use-mysqllatest-as-docker-image

I can understand why using the version number as the tag is best practice. I guess I'm used to devs posting only the latest stable version on that latest tag and using nightly for the latest unstable version.

I do use version tags for databases always. But I do agree with you.