containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.61k stars 2.4k forks source link

Running podman CLI as scheduled task in Windows #20770

Open D3vil0p3r opened 11 months ago

D3vil0p3r commented 11 months ago

Issue Description

I'm using Windows Server 2022 where I downloaded and installed 4.7.2 version of podman. I need to use Podman CLI instead of Podman Desktop so this executable installer is the right for me.

I need to run podman daemon at startup, so I created a scheduled task by Task Scheduler where I run "podman machine start" but it seems to not start anything when I run the scheduled task.

Steps to reproduce the issue

In particular, I created the scheduled task in the following manner:

General tab:
* user account is a domain account that is administrator of the Windows server (note that this account is also granted to run as batch job);
* Run whether user is logged or not
* Run with highest privileges
* Configure for: Windows Server 2022

Triggers tab:
* Begin the task: At startup
* Enabled option checked

Actions tab:
* Action: Start a program
* Program/Script: C:\Windows\System32\cmd.exe
* Add arguments: /k podman machine start

but I also tried:
* Program/Script: C:\Program Files\RedHat\Podman\podman.exe
* Add arguments: machine start

After its creation, I pressed on "Run" button in Task Scheduler application, but opening a new terminal and running "podman ps", I get:

Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:62414: connectex: No connection could be made because the target machine actively refused it.

so podman daemon seems to not be started.

Describe the results you received

Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:62414: connectex: No connection could be made because the target machine actively refused it.

Describe the results you expected

Podman daemon running correctly.

podman info output

host:
  arch: amd64
  buildahVersion: 1.32.0
  cgroupControllers:
  - cpuset
  - cpu
  - cpuacct
  - blkio
  - memory
  - devices
  - freezer
  - net_cls
  - perf_event
  - net_prio
  - hugetlb
  - pids
  - rdma
  - misc
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.1.7-2.fc38.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.7, commit: '
  cpuUtilization:
    idlePercent: 90.94
    systemPercent: 6.35
    userPercent: 2.71
  cpus: 8
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: container
    version: "38"
  eventLogger: journald
  freeLocks: 2047
  hostname: XDA-HOST
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.15.90.1-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 7792521216
  memTotal: 8329822208
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.8.0-1.fc38.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.8.0
    package: netavark-1.8.0-2.fc38.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.8.0
  ociRuntime:
    name: crun
    package: crun-1.11.2-1.fc38.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.11.2
      commit: ab0edeef1c331840b025e8f1d38090cfb8a0509d
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20231107.g56d9f6d-1.fc38.x86_64
    version: |
      pasta 0^20231107.g56d9f6d-1.fc38.x86_64
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.2-1.fc38.x86_64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 2147483648
  swapTotal: 2147483648
  uptime: 0h 0m 13.00s
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 1
    paused: 0
    running: 0
    stopped: 1
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 1081101176832
  graphRootUsed: 11830403072
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 2
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 4.7.2
  Built: 1698762611
  BuiltTime: Tue Oct 31 15:30:11 2023
  GitCommit: ""
  GoVersion: go1.20.10
  Os: linux
  OsArch: linux/amd64
  Version: 4.7.2

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

OS: Windows Server 2022

Additional information

I noticed https://github.com/containers/podman-desktop/pull/510 but I need to run podman daemon without Podman Desktop by a user account that is not logged in.

FF-AntiK commented 8 months ago

I have the same issue. I've logged the output of podman machine start:

Starting machine "podman-machine-default"
podman : T h e   f i l e   c a n n o t   b e   a c c e s s e d   b y   t h e   s y s t e m . 
At C:\Users\la-fferg\podman.ps1:1 char:1
+ podman machine start 2>&1 > output.txt
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (T h e   f i l e... s y s t e m . :String) [], RemoteE 
   xception
    + FullyQualifiedErrorId : NativeCommandError

 T h e   f i l e   c a n n o t   b e   a c c e s s e d   b y   t h e   s y s t e m . 

 Error: the WSL bootstrap script failed: exit status 1

I'm wondering what is the preferred way to autostart podman. Having to manually log in to my Windows Server machine on every restart seems a little bit odd to me..

Luap99 commented 6 months ago

@n1hility Do you have a idea here?

erVeroBoccia commented 4 weeks ago

I’m facing the same problem. What news?

benedikt-mue commented 3 weeks ago

Same issue. I think it has to do with WSL not being accessible by the system process before the user is logged in. I found a solution that worked by simply upgrading WSL to a pre-release:

wsl --update --pre-release

ref: https://github.com/microsoft/WSL/issues/8835