podman-py
podman-py copied to clipboard
Error if URI exceeds 64 characters
I have a uri like this
uri = "unix:///Users/muzammil.shahbaz/.local/share/containers/podman/machine/podman-machine-default/podman.sock" This exceeds the standard 64 characters.
On execution, I get the following error:
Exception has occurred: UnicodeError
encoding with 'idna' codec failed (UnicodeError: label empty or too long)
The above exception was the direct cause of the following exception:
File "../podmanclient.py", line 12, in <module>
version = client.version()
A potential fix would be to encode the URL to base64 and handle decoding in the code.
I am using podman version 4.1.1 on OSX using qemu virtual machine.
You can open the file and then use the path to the fd. In Go we do this with.
fd, err := unix.Open(path, unix.O_PATH, 0)
if err != nil {
return nil, err
}
defer unix.Close(fd)
return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d", fd), Net: "unixpacket"})
}
You can open the file and then use the path to the fd. In Go we do this with.
fd, err := unix.Open(path, unix.O_PATH, 0) if err != nil { return nil, err } defer unix.Close(fd) return net.DialUnix("unixpacket", nil, &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d", fd), Net: "unixpacket"}) }
Any idea how to do in python pls?
I couldn't quite figure out how to get the path to the file descriptor the way that they do with Go, but I found a different (albeit clunky) workaround here. It creates an SSH tunnel to a socket in a much easier to access (and shorter path) location: /tmp/podman.sock
. Its neither ideal nor pretty, but it gets the job done.
> podman system connection ls
# Create tunnel
> ssh -nNT -L/tmp/podman.sock:/run/user/1000/podman/podman.sock -i ~/.ssh/podman-machine-default ssh://core@localhost:[PORT]
# Export socket location
> export DOCKER_HOST='unix:///tmp/podman.sock'```