Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ toml = "0.8"
clap = { version = "4", features = ["derive", "env"] }

# Docker
bollard = "0.18"
bollard = { version = "0.18", features = ["ssl"] }

# Database
rusqlite = { version = "0.32", features = ["bundled"] }
Expand Down
1 change: 1 addition & 0 deletions coast-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ path = "src/bin/coast-dev.rs"

[dependencies]
coast-core = { path = "../coast-core" }
coast-docker = { path = "../coast-docker" }
coast-i18n = { path = "../coast-i18n" }
coast-update = { path = "../coast-update" }
rust-i18n = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions coast-cli/src/commands/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ pub async fn execute(args: &DoctorArgs) -> Result<()> {

let db = rusqlite::Connection::open(&db_path).context("Failed to open state database")?;

let docker = bollard::Docker::connect_with_local_defaults()
.context("Failed to connect to Docker. Is Docker running?")?;
let docker = coast_docker::host::connect_to_host_docker()
.context("Failed to connect to Docker. Is Docker running and is your active Docker context reachable?")?;

let mut fixes: Vec<String> = Vec::new();
let mut findings: Vec<String> = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion coast-cli/src/commands/nuke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub async fn execute(args: &NukeArgs) -> Result<()> {
..Default::default()
};

match bollard::Docker::connect_with_local_defaults() {
match coast_docker::host::connect_to_host_docker() {
Ok(docker) => {
report.containers_removed = remove_containers(&docker).await;
report.volumes_removed = remove_volumes(&docker).await;
Expand Down
8 changes: 7 additions & 1 deletion coast-daemon/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ pub struct AppState {
impl AppState {
/// Create a new `AppState` with the given state database and Docker client.
pub fn new(db: StateDb) -> Self {
let docker = bollard::Docker::connect_with_local_defaults().ok();
let docker = match coast_docker::host::connect_to_host_docker() {
Ok(docker) => Some(docker),
Err(error) => {
warn!(error = %error, "Docker is unavailable at daemon startup");
None
}
};
let (event_bus, _) = tokio::sync::broadcast::channel(256);
let initial_lang = db.get_language().unwrap_or_else(|_| "en".to_string());
let (language_tx, language_rx) = tokio::sync::watch::channel(initial_lang);
Expand Down
6 changes: 2 additions & 4 deletions coast-docker/src/dind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tracing::{debug, info};

use coast_core::error::{CoastError, Result};

use crate::host::connect_to_host_docker;
use crate::runtime::{BindMount, ContainerConfig, ExecResult, Runtime, VolumeMount};

/// The default Docker image used for DinD coast containers.
Expand All @@ -34,10 +35,7 @@ pub struct DindRuntime {
impl DindRuntime {
/// Create a new DinD runtime connected to the default Docker socket.
pub fn new() -> Result<Self> {
let docker = Docker::connect_with_local_defaults().map_err(|e| CoastError::Docker {
message: format!("Failed to connect to Docker daemon. Is Docker running? Error: {e}"),
source: Some(Box::new(e)),
})?;
let docker = connect_to_host_docker()?;
Ok(Self { docker })
}

Expand Down
Loading
Loading