podman
podman copied to clipboard
"podman machine start" should start default machine "defaultmachine" parameter from "podman machine info"
Feature request description
When running command podman machine start/stop/ssh/inspect without the machine name, it's always set the default machine to be executed to podman-machine-default.
I am not sure is this a same behavior on Linux/Mac also. On Linux, I am using native podman on the OS/Host, never try the podman with qemu/kvm backend on Linux.
When initialize podman on windows (podman machine on top WSL), the default machine is "podman-machine-default".
PS C:\Users\user> podman machine list
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE
PS C:\Users\user>
PS C:\Users\user>
PS C:\Users\user> podman machine init
Extracting compressed file: podman-machine-default-amd64: done
Importing operating system into WSL (this may take a few minutes on a new WSL install)...
Import in progress, this may take a few minutes.
The operation completed successfully.
Configuring system...
Machine init complete
To start your machine run:
podman machine start
PS C:\Users\user>
# This also create WSL instance on the host
PS C:\Users\thur> wsl -l -v
NAME STATE VERSION
* podman-machine-default Stopped 2
It's actually running without no issue.
However, when we create single/multiple podman machines with custom name. The podman machine ... command not works to execute podman machine related command on the customized podman machine's name. Even if we set the defaultmachine to other podman machine.
PS C:\Users\user> podman machine init podman
Extracting compressed file: podman-amd64: done
Importing operating system into WSL (this may take a few minutes on a new WSL install)...
Import in progress, this may take a few minutes.
The operation completed successfully.
Configuring system...
Machine init complete
To start your machine run:
podman machine start podman
PS C:\Users\user>
Default machine is podman-machine-default as expected:
PS C:\Users\user> podman machine list
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE
podman-machine-default* wsl 55 seconds ago Never 10 2GiB 100GiB
podman wsl 25 seconds ago Never 10 2GiB 100GiB
PS C:\Users\user> podman system connection list
Name URI Identity Default ReadWrite
podman ssh://[email protected]:63102/run/user/1000/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
podman-machine-default ssh://[email protected]:63091/run/user/1000/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine true true
podman-machine-default-root ssh://[email protected]:63091/run/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
podman-root ssh://[email protected]:63102/run/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
PS C:\Users\user> podman machine info
host:
arch: amd64
currentmachine: podman-machine-default
defaultmachine: podman-machine-default
eventsdir: C:\Users\user\.local\share\containers\podman\podman
machineconfigdir: C:\Users\user\.config\containers\podman\machine\wsl
machineimagedir: C:\Users\user\.local\share\containers\podman\machine\wsl
machinestate: Stopped
numberofmachines: 2
os: windows
vmtype: wsl
version:
apiversion: 5.1.2
version: 5.1.2
goversion: go1.22.5
gitcommit: 94a24974ab345324db1a1489c924af4b89d2d0e9
builttime: Wed Jul 10 22:01:39 2024
built: 1720623699
osarch: windows/amd64
os: windows
PS C:\Users\user> wsl -l -v
NAME STATE VERSION
* podman-machine-default Stopped 2
podman Stopped 2
Then we try to change the default podman machine/connection.
PS C:\Users\user> podman system connection default podman
PS C:\Users\user> podman machine list
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE
podman-machine-default wsl 4 minutes ago About a minute ago 10 2GiB 100GiB
podman* wsl 3 minutes ago Never 10 2GiB 100GiB
PS C:\Users\user> podman system connection list
Name URI Identity Default ReadWrite
podman ssh://[email protected]:63102/run/user/1000/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine true true
podman-machine-default ssh://[email protected]:63091/run/user/1000/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
podman-machine-default-root ssh://[email protected]:63091/run/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
podman-root ssh://[email protected]:63102/run/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
PS C:\Users\user> podman machine info
host:
arch: amd64
currentmachine: podman
defaultmachine: podman
eventsdir: C:\Users\user\.local\share\containers\podman\podman
machineconfigdir: C:\Users\user\.config\containers\podman\machine\wsl
machineimagedir: C:\Users\user\.local\share\containers\podman\machine\wsl
machinestate: Stopped
numberofmachines: 2
os: windows
vmtype: wsl
version:
apiversion: 5.1.2
version: 5.1.2
goversion: go1.22.5
gitcommit: 94a24974ab345324db1a1489c924af4b89d2d0e9
builttime: Wed Jul 10 22:01:39 2024
built: 1720623699
osarch: windows/amd64
os: windows
Change the default podman machine/connection:
# Set default podman connection
PS C:\Users\user> podman system connection default podman
# verify the default machine/connection
PS C:\Users\user> podman machine list
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE
podman-machine-default wsl 4 minutes ago About a minute ago 10 2GiB 100GiB
podman* wsl 3 minutes ago Never 10 2GiB 100GiB
# List connection
PS C:\Users\user> podman system connection list
Name URI Identity Default ReadWrite
podman ssh://[email protected]:63102/run/user/1000/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine true true
podman-machine-default ssh://[email protected]:63091/run/user/1000/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
podman-machine-default-root ssh://[email protected]:63091/run/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
podman-root ssh://[email protected]:63102/run/podman/podman.sock C:\Users\user\.local\share\containers\podman\machine\machine false true
# Verify `defaultmachine` has been set to expected value
PS C:\Users\user> podman machine info
host:
arch: amd64
currentmachine: podman
defaultmachine: podman
eventsdir: C:\Users\user\.local\share\containers\podman\podman
machineconfigdir: C:\Users\user\.config\containers\podman\machine\wsl
machineimagedir: C:\Users\user\.local\share\containers\podman\machine\wsl
machinestate: Stopped
numberofmachines: 2
os: windows
vmtype: wsl
version:
apiversion: 5.1.2
version: 5.1.2
goversion: go1.22.5
gitcommit: 94a24974ab345324db1a1489c924af4b89d2d0e9
builttime: Wed Jul 10 22:01:39 2024
built: 1720623699
osarch: windows/amd64
os: windows
However, even the defaultmachine parameter from podman machine info command output has been set to the expected value, the default machine started using podman machine start command still refering to the podman-machine-default:
PS C:\Users\user> podman machine start
Starting machine "podman-machine-default"
This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:
podman machine set --rootful
API forwarding listening on: npipe:////./pipe/docker_engine
Docker API clients default to this address. You do not need to set DOCKER_HOST.
Machine "podman-machine-default" started successfully
Podman machine with custom name still need to be specified as parameter to start, stop, ssh the machine:
PS C:\Users\user> podman machine start podman
Starting machine "podman"
This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:
podman machine set --rootful podman
API forwarding listening on: npipe:////./pipe/podman
Another process was listening on the default Docker API pipe address.
You can still connect Docker API clients by setting DOCKER HOST using the
following powershell command in your terminal session:
$Env:DOCKER_HOST = 'npipe:////./pipe/podman'
Or in a classic CMD prompt:
set DOCKER_HOST=npipe:////./pipe/podman
Alternatively, terminate the other process and restart podman machine.
Machine "podman" started successfully
Other podman machine ... command still executed to podman-machine-default:
PS C:\Users\user> podman machine ls
NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE
podman* wsl 32 minutes ago Currently running 10 2GiB 100GiB
podman-machine-default wsl 33 minutes ago Currently running 10 2GiB 100GiB
PS C:\Users\user> podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
Last login: Sun Jul 21 14:04:44 2024 from ::1
[user@host ~]$
[user@host ~]$ podman version
WARN[0000] Using cgroups-v1 which is deprecated in favor of cgroups-v2 with Podman v5 and will be removed in a future version. Set environment variable `PODMAN_IGNORE_CGROUPSV1_WARNING` to hide this warning.
Client: Podman Engine
Version: 5.1.1
API Version: 5.1.1
Go Version: go1.22.3
Built: Tue Jun 4 07:00:00 2024
OS/Arch: linux/amd64
Changing the default wsl seem not related to this behavior:
PS C:\Users\user> wsl -l -v
NAME STATE VERSION
* podman-machine-default Running 2
podman Running 2
PS C:\Users\user> wsl --set-default podman
The operation completed successfully.
PS C:\Users\user> wsl -l -v
NAME STATE VERSION
* podman Running 2
podman-machine-default Running 2
PS C:\Users\user> podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
Last login: Sun Jul 21 14:05:21 2024 from ::1
[user@dunia ~]$
[user@dunia ~]$ podman -v
podman version 5.1.1
Suggest potential solution
The podman machine cotext when podman machine start/stop/ssh/inspect command executed without machine name will be set to machine based on defaultmachine value from podman machine info
Have you considered any alternatives?
No response
Additional context
No response
I am not a Golang developer 😄 but the command behavior seems related to this snippet:
Default machine for podman machine start command:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/start.go#L45-L53
Default machine for podman machine stop command:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/stop.go#L37-L45
Default machine for podman machine ssh command:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/ssh.go#L63-L83
Default machine for podman machine inspect command:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/inspect.go#L47-L57
Default machine for podman machine rm command:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/rm.go#L49-L56
Default machine for podman machine set command:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/set.go#L90-L94
All of defaultMachineName variable from above code related to podman machine ... command seems referring to the hard-coded defaultMachineName = machine.DefaultMachineName in cmd/podman/machine/init.go
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/init.go#L21-L37
And the DefaultMachineName variable value is set to podman-machine-default in pkg/machine/config.go
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/pkg/machine/config.go#L23-L26
However, the podman machine info seem have different (expected) behavior to get the value for defaultmachine:
https://github.com/containers/podman/blob/94a24974ab345324db1a1489c924af4b89d2d0e9/cmd/podman/machine/info.go#L114-L150
I am not sure is this a kind of bug or expected behavior.
this seems like a bug to me
WDYT @Luap99 @ashley-cui
What part? My understanding is that name is hard coded for the cli parsing for machine commands.
The normal remote client uses connections so it uses whatever is set as default connection, this is completely unrelated to machines. Using the remote client does not need any machines at all.
So is the question is why does machine info uses connection to show the default? Then I don't know but machine ls does the same AFAIK.
sorry I definitely wasn't clear... I meant it seemed odd to me that machine info was using system connections to determine the default when the other commands determined that differently
A friendly reminder that this issue had no activity for 30 days.
This one seems to have gotten lost, do we need to just fix podman machine info to show the default connection?
This one seems to have gotten lost, do we need to just fix
podman machine infoto show the default connection?
Yes. I can fix it
Info does show the default connection? I don't think this is a bug, as info is designed to show the state of the system, and the default connection is much more relevant than just showing "podman-machine-info"
Shouldn't the defaultmachine section always show podman-machine-default since that's technically the default machine we would try and run if the user didn't specify a name?
If the default system connection is set to something that isn't associated with a podman machine then defaultmachine just shows "" which a little confusing considering there technically is a default
I guess it's a naming issue then? IMO displaying podman-machine-default in podman machine info doesn't make sense because it doesn't give the user more info. The behavior of knowing what machine your connection is going to speak to is useful, and what machine is running is useful. Maybe it should be something like machineactiveconnection? or something like that?
A name change sounds like a good way to go about this. machineactiveconnection works for me as well
Hi @kgfathur!
For the foreseeable future the current behavior will remain. I do want to clarify that defaultmachine in the podman machine info output is not meant to suggest you are able to set a "default" podman machine. The default podman machine will always be podman-machine-default. defaultmachine is intended to specify, if it exists, the current default system connection that is associated with a podman machine.
In order to make this clearer, I updated the podman machine info manpages to outline this information. (https://github.com/containers/podman/pull/23841)
For the next major podman release, the idea is to change the name to something along the lines of activemachineconnection to better describe its behavior.
I'm going to leave this issue open so we can track it for the next release. Thanks for filing your issue!