diff --git a/cup.schema.json b/cup.schema.json index f3c4e22..5d95851 100644 --- a/cup.schema.json +++ b/cup.schema.json @@ -70,7 +70,7 @@ }, "socket": { "type": "string", - "description": "The path to the unix socket you would like Cup to use for communication with the Docker daemon. Useful if you're trying to use Cup with Podman.", + "description": "The path to the unix socket you would like Cup to use for communication with the Docker daemon. Useful if you're trying to use Cup with Podman. To disable use \"none\" as value.", "minLength": 1 }, "servers": { diff --git a/docs/src/content/docs/configuration/index.mdx b/docs/src/content/docs/configuration/index.mdx index 1c1f595..5bda255 100644 --- a/docs/src/content/docs/configuration/index.mdx +++ b/docs/src/content/docs/configuration/index.mdx @@ -23,7 +23,7 @@ For example, if using Podman, you might do $ cup -s /run/user/1000/podman/podman.sock check ``` -This option is also available in the configuration file and it's best to put it there. +This option is also available in the configuration file and it's best to put it there. If both are defined the CLI `-s` option takes precedence. } @@ -31,6 +31,8 @@ This option is also available in the configuration file and it's best to put it href="/docs/configuration/socket" /> +To disable Docker/Podman socket use "none" as value. + ## Configuration file Cup has an option to be configured from a configuration file named `cup.json`. diff --git a/docs/src/content/docs/configuration/socket.mdx b/docs/src/content/docs/configuration/socket.mdx index 395dda6..81074fd 100644 --- a/docs/src/content/docs/configuration/socket.mdx +++ b/docs/src/content/docs/configuration/socket.mdx @@ -17,3 +17,12 @@ You can also specify a TCP socket if you're using a remote Docker host or a [pro // Other options } ``` + +Or use the "none" value to disable any Docker/Podman query: + +```jsonc +{ + "socket": "none" + // Other options +} +``` diff --git a/src/docker.rs b/src/docker.rs index 9d31d3e..633f2e6 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -41,6 +41,9 @@ pub async fn get_images_from_docker_daemon( ctx: &Context, references: &Option>, ) -> Vec { + if ctx.config.socket.as_deref() == Some("none") { + return vec![]; + } let client: Docker = create_docker_client(ctx.config.socket.as_deref()); let mut swarm_images = match client.list_services::(None).await { Ok(services) => services @@ -96,6 +99,10 @@ pub async fn get_images_from_docker_daemon( } pub async fn get_in_use_images(ctx: &Context) -> Vec { + if ctx.config.socket.as_deref() == Some("none") { + return vec![]; + } + let client: Docker = create_docker_client(ctx.config.socket.as_deref()); let containers = match client