-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access docker api on a mac #11397
Comments
I think you need to specify DOCKER_HOST environment variable for this, but this is where my knowledge ends. |
As Dan mentioned |
However it still my happen that some application wrongly assume that socket is always |
On the mac I see -
Indeed, /run/user/1000/podman/podman.sock doesn't exist on the mac, only inside the podman machine. |
oh my bad, you need to specify protocol too |
I'm not seeing how the socket would work if its inside the podman machine. |
it can be made to work i think, the problem is a little more sophisticated than the network connection I am afraid. i'm looking into casually, but the first issue is the presence of moby on the os. |
Many thanks :-) |
@baude isn't |
We ended up symlinking inside the VM, since the location of the unix socket is hardcoded (when using
So had to remove the To work in CoreOS, you first have to $ podman machine ssh
Connecting to vm podman-machine-default. To close connection, use `~.` or `exit`
Fedora CoreOS 34.20210821.1.1
Tracker: https://github.com/coreos/fedora-coreos-tracker
Discuss: https://discussion.fedoraproject.org/c/server/coreos/
[core@localhost ~]$ sudo systemctl stop docker.socket
[core@localhost ~]$ sudo rm /var/run/docker.sock
[core@localhost ~]$ sudo ln -s /run/podman/podman.sock /var/run/docker.sock
[core@localhost ~]$ sudo docker version
Client:
Version: 20.10.7
API version: 1.40
Go version: go1.16.5
Git commit: f0df350
Built: Fri Jul 16 12:30:15 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: linux/amd64/fedora-34
Podman Engine:
Version: 3.3.0
APIVersion: 3.3.0
Arch: amd64
BuildTime: 2021-08-20T19:36:14Z
Experimental: true
GitCommit:
GoVersion: go1.16.6
KernelVersion: 5.13.12-200.fc34.x86_64
MinAPIVersion: 3.1.0
Os: linux
Engine:
Version: 3.3.0
API version: 1.40 (minimum version 1.24)
Go version: go1.16.6
Git commit:
Built: Fri Aug 20 19:36:14 2021
OS/Arch: linux/amd64
Experimental: true
[core@localhost ~]$ exit Now it will work with the URL from $ podman system connection ls
Name Identity URI
podman-machine-default* /home/anders/.ssh/podman-machine-default ssh://core@localhost:45271/run/user/1000/podman/podman.sock
podman-machine-default-root /home/anders/.ssh/podman-machine-default ssh://root@localhost:45271/run/podman/podman.sock
And similar for the rootless socket. (located in the VM at EDIT: You also need to |
yeah docker doesn't support unix socket over ssh it seems, but I can be worked around using ssh tunnel |
It does support the socket, it just hardcodes the location. So I guess it doesn't support giving a path. And apparently CoreOS still ships with Docker, so it will actually start the real dockerd instead... |
what I mean you can have something like |
|
The command above basically tunnels remote unix socket to you local machine. |
At least this seems to be true for standard podman is better at this since CONTAINER_HOST can be |
I played with this when I tried to connect to podman running in CRC OpenShift VM. |
Ah I missed that it's VM via ssh. Then you probably need to workaround this using ssh tunnel. |
@afbjorklund symlink solution looks better that using ssh tunnel, I myself used tunnel in past because my VM didn't allow me create symlinks. |
We had to use the tunnel hack for containerd/buildkitd, they are even worse than Docker when it comes to remoting. https://minikube.sigs.k8s.io/docs/handbook/pushing/ For Podman it is mostly that the name of binary changes, once we get past the whole Varlink business in ancient history. (and maybe |
Ah ha :-) So following the sym link approach I got to -
But then in my next use-case, fabric8 maven plugin -
I'll try the tunnel approach. |
seems like flaw of the java lib |
Well, if docker client doesn't support ssh and podman server doesn't support tcp - I guess you are left to tunneling unix over ssh. I think Docker has some way of presenting a unix socket from the VM at https://web.archive.org/web/20190623234611/https://docs.docker.com/docker-for-mac/docker-toolbox/ Some kind of virtual sockets. |
I believe podman can be set to use plain TCP. |
e.g. |
but I don't know how the |
and even if it didn't support TCP you still could use @afbjorklund what problems did you encountered with tunneling? |
It's a bunch of arcane commands, instead of an URL in a variable. So it's hard to explain to the end users, that just want to "run Docker". It probably doesn't work on Windows either, but then again what does... |
A friendly reminder that this issue had no activity for 30 days. |
This would be really nice to have! |
Agreed. |
A friendly reminder that this issue had no activity for 30 days. |
A friendly reminder that this issue had no activity for 30 days. |
thanks @tibcoplord, it works well on my MacOS BigSur.
I use this command to get the port number Then run these commands to create tunnel over SSH
|
thanks @n0rig, the simplest way as you mentioned:
I use |
please note the following actually helped to make it work. Thanks for your help. You all rock. user is per system so is port
Key Takeaway Commands to execute to make it work
|
The socket address is actually printed in the output of You can still connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:
export DOCKER_HOST='unix:///Users/davidhyc/.local/share/containers/podman/machine/podman-machine-default/podman.sock' Maybe we just need to make that info more accessible (e.g., printed by some command)? ➜ ~ podman system connection ls
Name URI Identity Default
podman-machine-default ssh://core@localhost:63594/run/user/504/podman/podman.sock /Users/davidhyc/.ssh/podman-machine-default true
podman-machine-default-root ssh://root@localhost:63594/run/podman/podman.sock /Users/davidhyc/.ssh/podman-machine-default false |
Would you expect that same line to print out again there, if you have a podman machine running? |
Thanks for the response. I think that would work. Or anywhere under the |
Please open a new issue on this. |
/kind feature
Description
I've been following https://github.com/containers/podman/blob/main/docs/tutorials/mac_experimental.md on my mac, specifically -
Actually works pretty well :-) However next I want to use a docker client ( specifically the fabric8 maven plugin to build images, but we can test with docker command ), but I see -
I read at https://github.com/containers/podman/blob/main/docs/source/markdown/podman-system-service.1.md that there is an option to provide the API service, but this fails with -
Steps to reproduce the issue:
Describe the results you received:
Error: unrecognized command
podman system service
Describe the results you expected:
Able to connect to the socket from a docker client (outside the machine)
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Additional environment details (AWS, VirtualBox, physical, etc.):
mac client with podman machine running.
I did wonder if the technique I need is to somehow tunnel the socket running inside the podman machine to outside ... but I couldn't find this in the docs.
The text was updated successfully, but these errors were encountered: