KilledByCHeese
KilledByCHeese

Reputation: 872

Traefik Proxy Setup with Podman on Windows utilizing podman-compose

I am using Podman on Windows (https://github.com/containers/podman/blob/main/docs/tutorials/podman-for-windows.md) together with podman-compose (https://github.com/containers/podman-compose?tab=readme-ov-file#pip)

>podman --version
 podman version 5.0.2

>podman machine inspect
[
     {
          "ConfigDir": {
               "Path": "C:\\Users\\...\\.config\\containers\\podman\\machine\\wsl"
          },
          "ConnectionInfo": {
               "PodmanSocket": null,
               "PodmanPipe": {
                    "Path": "\\\\.\\pipe\\podman-machine-default"
               }
          },
          "Created": "2024-10-28T17:01:13.1163465+01:00",
          "LastUp": "0001-01-01T00:00:00Z",
          "Name": "podman-machine-default",
          "Resources": {
               "CPUs": 10,
               "DiskSize": 100,
               "Memory": 2048,
               "USBs": []
          },
          "SSHConfig": {
               "IdentityPath": "C:\\Users\\...\\.local\\share\\containers\\podman\\machine\\machine",
               "Port": 56403,
               "RemoteUsername": "user"
          },
          "State": "running",
          "UserModeNetworking": false,
          "Rootful": true
     }
]


>podman-compose --version
podman-compose version: 1.0.6

I have a compose.yaml file where I try to setup a Traefik Proxy for my Services:

services:

reverse-proxy:
  container_name: traefik-reverse-proxy
  image: traefik:v3.1
  command:
    - "--api.insecure=true"
    - "--api.dashboard=true"
    - "--providers.docker=true"
    - "--providers.docker.exposedbydefault=false"
    - "--entrypoints.web.address=:80"
  ports:
    - "80:80"
    - "8080:8080"  # Traefik dashboard
  volumes:
    - "/var/run/docker.sock:/var/run/docker.sock"  
  restart: unless-stopped
  labels:
    - "traefik.enable=true"
    - "traefik.http.routers.api.rule=Host(`traefik.localhost`)"

backend:
  depends_on: 
    - reverse-proxy 
  container_name: my-api-container
  image: gitlab-registry....:latest
  pull_policy: always
  restart: unless-stopped
  labels:
    - "traefik.enable=true"
    - "traefik.http.routers.backend.rule=Host(`backend.localhost`)"
    - "traefik.http.routers.backend.entrypoints=web"

after running podman-compose up -d I can access the Traefik dashboard under http://traefik.localhost:8080/dashboard/#/, but not my Backend-Container.
Upon executing podman logs -t traefik-reverse-proxy following errors are shown:

ERR Failed to retrieve information of the docker client and server host error="Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" providerName=docker
ERR Provider error, retrying in 318.953454ms error="Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?" providerName=docker  

How do I need to adjust my compose.yaml/Traefik config in order to successfully use Traefik Proxy with Podman-Compose on Windows?

When I try and use the npipe to map the volume in the compose.yaml:

volumes:
  - "//./pipe/podman-machine-default:/var/run/docker.sock" 

I get the Error:

OSError: [WinError 231] All pipe instances are busy: '\\\\.\\pipe\\podman-machine-default'

Upvotes: 0

Views: 192

Answers (1)

Claudio Weiler
Claudio Weiler

Reputation: 669

Docker socket mapping with podman should be something like this:

/run/user/<user>/podman/podman.sock:/var/run/docker.sock:z

Podman socket must be started with:

$ systemctl --user start podman.socket

Reference: https://blog.cthudson.com/2023-11-02-running-traefik-with-podman/

Upvotes: 0

Related Questions