Skip to content

armgit / kokon

Public Imported from GitHub
0

Edit photos by describing the change, on your own GPU. A free, open-source alternative to Nano Banana and ChatGPT image editing: photos stay on your computer, no daily limit. One installer for Windows, Mac and Linux sets up the best open model (Qwen-Image 2.1). MCP server for AI agents.

Docker: the start-up message names the published port, not the container's own addresses

Gabriele Lozuponea1874dd5db71
diff --git a/crates/qls-service/src/main.rs b/crates/qls-service/src/main.rs
index 370ca3d..b74acf3 100644
--- a/crates/qls-service/src/main.rs
+++ b/crates/qls-service/src/main.rs
@@ -118,6 +118,11 @@ pub fn say(line: &str) {
let _ = out.flush();
}
+/// Running in Kokon's Docker image.
+pub fn in_container() -> bool {
+ std::env::var_os("KOKON_CONTAINER").is_some()
+}
+
pub fn service_info_path() -> PathBuf {
data_dir().join("service.json")
}
@@ -310,7 +315,11 @@ async fn run(args: Vec<String>) {
remote: remote::RemoteState::new(&dir, forced_remote),
});
say(&format!("Kokon {APP_VERSION} is running."));
- say(&format!(" On this computer: http://localhost:{port}"));
+ // In the Docker image (KOKON_CONTAINER, docker/Dockerfile) the loopback port and the container's
+ // own address mean nothing outside: name the published port instead (remote.rs).
+ if !in_container() {
+ say(&format!(" On this computer: http://localhost:{port}"));
+ }
remote::sync_listener(&state);
let cfg_now = engine.config();
if forced_remote && !state.remote.password_set() {
diff --git a/crates/qls-service/src/remote.rs b/crates/qls-service/src/remote.rs
index be6d114..ead1c02 100644
--- a/crates/qls-service/src/remote.rs
+++ b/crates/qls-service/src/remote.rs
@@ -168,9 +168,13 @@ pub fn sync_listener(state: &Arc<AppState>) {
});
tracing::info!("access from other devices open on port {port} (all interfaces)");
let here = format!("http://localhost:{port}");
- match lan_address() {
+ if crate::in_container() {
+ crate::say(&format!(" Open in a browser: {here} on the computer running Docker, or http://<its address>:{port} from other devices (password required)"));
+ } else {
+ match lan_address() {
Some(ip) => crate::say(&format!(" Other devices: http://{ip}:{port} (password required; {here} here)")),
None => crate::say(&format!(" Other devices: port {port} of this computer's address (password required; {here} here)")),
+ }
}
*r.error.lock().unwrap() = None;
*cur = Some(Lan { port, task });
diff --git a/docker/Dockerfile b/docker/Dockerfile
index d9b99c6..8c11658 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -37,7 +37,7 @@ ENV QLS_DATA_DIR=/data \
QLS_CONFIG_DIR=/config \
QLS_OUTPUT_DIR=/gallery \
NVIDIA_VISIBLE_DEVICES=all \
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
+ NVIDIA_DRIVER_CAPABILITIES=compute,utility KOKON_CONTAINER=1
USER kokon
VOLUME ["/data", "/config", "/gallery"]
# The browser UI (password required). The token API on 39151 stays inside the container.