Skip to content

Commit 5569f35

Browse files
authored
add: enable working with a remote daemon (#37)
1 parent 0668aab commit 5569f35

File tree

5 files changed

+213
-16
lines changed

5 files changed

+213
-16
lines changed

Cargo.lock

+183-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "rooz"
3-
version = "0.59.0"
3+
version = "0.60.0"
44
edition = "2021"
55

66
[dependencies]
77
base64 = "0.21.3"
8-
bollard = "0.15.0"
8+
bollard = { version = "0.15.0", features = ["ssl"] }
99
#bollard = { git = "https://github.com/fussybeaver/bollard.git" }
1010

1111
clap = { version = "4.4.2", features = ["derive", "env"] }

README.md

+16
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,22 @@ Supported keywords:
184184

185185
* auto-resizing rooz session to fit the terminal window (if resized) is not implemented. Workaround: exit the session, resize the window to your liking, enter the container.
186186

187+
## Connecting to a remote Docker host
188+
189+
Rooz connects to a local Docker daemon by default. However, it also supports working with
190+
a remote mTLS-protected Docker socket.
191+
192+
:warning: make sure the Docker daemon has [remote access enabled](https://docs.docker.com/config/daemon/remote-access/) and is [mTLS-protected](https://docs.docker.com/engine/security/protect-access/#create-a-ca-server-and-client-keys-with-openssl)
193+
194+
Configure rooz to connect to a remote daemon:
195+
196+
* env: `export ROOZ_REMOTE=true`
197+
* env: `export DOCKER_HOST=tcp://X.X.X.X:2376`
198+
* make sure you have the following files in `~/.docker/`:
199+
* `ca.pem` (Docker daemon's CA cert)
200+
* `cert.pem` (Your client cert)
201+
* `key.pem` (Your client key)
202+
187203
## Running with Podman
188204

189205
1. Make sure podman remote socket is enabled:

src/cli.rs

+2
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,6 @@ pub enum Commands {
167167
pub struct Cli {
168168
#[command(subcommand)]
169169
pub command: Commands,
170+
#[arg(hide = true, env = "ROOZ_REMOTE")]
171+
pub env_remote: Option<bool>,
170172
}

src/main.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ async fn main() -> Result<(), AnyError> {
3535
log::debug!("Started");
3636

3737
let args = Cli::parse();
38-
let docker = Docker::connect_with_local_defaults().expect("Docker API connection established");
38+
39+
let connection = if let Cli{env_remote:Some(true), command:_ } = args {
40+
Docker::connect_with_ssl_defaults()
41+
} else {
42+
Docker::connect_with_local_defaults()
43+
};
44+
45+
let docker = connection.expect("Docker API connection established");
46+
3947
log::debug!("Client ver: {}", &docker.client_version());
4048

4149
let version = &docker.version().await?;
@@ -203,12 +211,7 @@ async fn main() -> Result<(), AnyError> {
203211
.await?
204212
}
205213

206-
Cli {
207-
command:
208-
System(cli::System {
209-
command: cli::SystemCommands::Completion(CompletionParams { shell }),
210-
}),
211-
} => {
214+
Cli {command:System(cli::System{command:cli::SystemCommands::Completion(CompletionParams{shell}),}), env_remote: _ } => {
212215
let mut cli = Cli::command()
213216
.disable_help_flag(true)
214217
.disable_help_subcommand(true);

0 commit comments

Comments
 (0)