Skip to content
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

Don't require the docker client to be present #163

Open
Michael-F-Bryan opened this issue Nov 24, 2017 · 3 comments
Open

Don't require the docker client to be present #163

Michael-F-Bryan opened this issue Nov 24, 2017 · 3 comments

Comments

@Michael-F-Bryan
Copy link

I'm trying to use cross in my CI jobs to cross-compile a library so I can provide precompiled binaries to my users. It looks like cross currently shells out to the docker program, meaning you need to have the client installed on your machine in order to use cross.

I know there's at least one docker client available on crates.io. What are your thoughts on trying to use something like that instead of requiring the docker client to be installed?

@jamesmunns
Copy link
Contributor

Hey @Michael-F-Bryan, I'm open to the idea, but would not know how to implement that. I would be happy to review a PR for it though!

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 2, 2022

rust-docker currently hasn't been maintained in over 7 years, and we support much more than just Docker now (including podman, and I've gotten Lima to work as well), and this still requires a docker daemon running. It uses the try! macro as well, so it's well before Rust 1.0.

Not all container engines with a CLI API compatible with Docker will necessarily use a client/server architecture, and we'd have to listen on different endpoints. For example, podman by default doesn't use expose a socket for an HTTP API in rootless mode, although it can if enabled. For example, we'd need to probe the following locations, and support an entirely different API:

  • /var/run/docker.sock
  • /run/user/$UID/podman/podman.sock
$ curl --unix-socket /run/user/1000/podman/podman.sock http://localhost/v1.41/images/json

We'd also need to support the following tools:

  • docker inspect
  • docker run
  • docker cp
  • docker exec
  • docker images
  • docker stop
  • docker volume
  • docker rm
  • docker ps

A lot of this is due to remote Docker support. I'm not entirely sure if that's worth it. We may be able to support this if CROSS_CONTAINER_ENGINE_SOCKET was provided, but it would be a lot of code.

Probably the best solution now would be to use bollard, but because this has numerous dependencies with major compile-time overhead, it would require feature-gating it. We'd also need to make sure this other code-path does not go out-of-sync with our default code.

If anyone wants to contribute, that would be great, but it would need:

  • Wrappers for commands to ensure our CLI and bollard-based APIs would be identical
  • Be feature-gated
  • Provide an API for the socket/gateway path
  • Tests to ensure it works

Other downsides include that it would not work with lima (except when emulating docker/podman) and likely other container engines.

@Alexhuszagh
Copy link
Contributor

This might still be possible, we just need to add on the following requirements:

Would require CROSS_CONTAINER_ENGINE_SOCKET or assuming the defaults. In short, everything could be done via bollard, I believe.

The steps required would be as follows:

  1. Convert into api, shell, and client submodules in the docker docker module.
  2. Structify the data that needs to be passed.
  3. Create API functions that automatically call the shell variant.

Then, when implementing client:

  1. Feature gate client.
  2. Implement into for the structified data to the bollard structs.
  3. Implement client API functions.
  4. Change api to use shell or client depending on some environment variable or config option if the client feature is enabled.

This is doable, and maybe less work than initially imagined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants