Skip to content

Commit ac5996b

Browse files
fix: force claude desktop cowork host backend
1 parent 4d17596 commit ac5996b

8 files changed

Lines changed: 127 additions & 15 deletions

File tree

Docker-Images/Designer/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ rm /tmp/opencode-desktop.deb
131131
rm -rf /var/lib/apt/lists/*
132132
EOSH
133133

134+
ENV COWORK_VM_BACKEND=host
135+
134136
# Claude Desktop (.deb repo comunitario) + wrapper no-sandbox para Electron
135137
RUN <<'EOSH'
136138
set -e
@@ -143,8 +145,8 @@ if [ -x /usr/share/claude-desktop/claude-desktop ] && [ -x /usr/bin/claude-deskt
143145
mv /usr/bin/claude-desktop /usr/bin/claude-desktop.real || true
144146
cat > /usr/bin/claude-desktop <<'EOFWRAP'
145147
#!/bin/sh
146-
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}" \
147-
/usr/share/claude-desktop/claude-desktop --no-sandbox --disable-gpu-sandbox --disable-setuid-sandbox --disable-seccomp-filter-sandbox --no-zygote --disable-gpu "$@"
148+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="${COWORK_VM_BACKEND:-host}" \
149+
/usr/bin/claude-desktop.real "$@"
148150
EOFWRAP
149151
chmod +x /usr/bin/claude-desktop
150152
fi

Docker-Images/Developer/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ RUN set -e; \
197197
# Electron apps dentro de contenedores Docker necesitan desactivar el sandbox
198198
# (no hay user namespaces). Los wrappers añaden --no-sandbox y pistas de Ozone.
199199
ENV ELECTRON_DISABLE_SANDBOX=1 \
200-
ELECTRON_OZONE_PLATFORM_HINT=auto
200+
ELECTRON_OZONE_PLATFORM_HINT=auto \
201+
COWORK_VM_BACKEND=host
201202
RUN <<'EOSH'
202203
set -e
203204
wrap() {
@@ -206,15 +207,23 @@ wrap() {
206207
mv "$name" "${name}.real" || true
207208
cat > "$name" <<SHWRAP
208209
#!/bin/sh
209-
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}" \
210+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="${COWORK_VM_BACKEND:-host}" \
210211
"$target" --no-sandbox --disable-gpu-sandbox --disable-setuid-sandbox --disable-seccomp-filter-sandbox --no-zygote $EXTRA_FLAGS "$@"
211212
SHWRAP
212213
chmod +x "$name"
213214
fi
214215
}
215216
TARGET_BIN=/usr/lib/github-desktop/github-desktop EXTRA_FLAGS="--password-store=basic" wrap /usr/bin/github-desktop /usr/lib/github-desktop/github-desktop
216-
TARGET_BIN=/usr/share/claude-desktop/claude-desktop EXTRA_FLAGS="--disable-gpu" wrap /usr/bin/claude-desktop /usr/share/claude-desktop/claude-desktop
217217
TARGET_BIN=/usr/share/code/bin/code EXTRA_FLAGS="" wrap /usr/bin/code /usr/share/code/bin/code
218+
if [ -x /usr/bin/claude-desktop ]; then
219+
mv /usr/bin/claude-desktop /usr/bin/claude-desktop.real || true
220+
cat > /usr/bin/claude-desktop <<'EOFWRAP'
221+
#!/bin/sh
222+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="${COWORK_VM_BACKEND:-host}" \
223+
/usr/bin/claude-desktop.real "$@"
224+
EOFWRAP
225+
chmod +x /usr/bin/claude-desktop
226+
fi
218227
# Google Chrome (no es Electron pero también necesita --no-sandbox en Docker)
219228
if [ -x /opt/google/chrome/google-chrome ]; then
220229
mv /usr/bin/google-chrome-stable /usr/bin/google-chrome-stable.real 2>/dev/null || true

workspaces/AdvancedHostDANGER/main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,28 @@ PULSECFG
198198
# COWORK_VM_BACKEND=host evita que Claude Desktop use bwrap (que falla en contenedores)
199199
# El contenedor Docker ya provee el aislamiento necesario
200200
COWORK_TAG="# managed-by-danger-template: cowork-vm-backend"
201-
if ! grep -qF "$COWORK_TAG" "$HOME/.xsessionrc" 2>/dev/null; then
202-
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$HOME/.xsessionrc"
201+
for cowork_file in "$HOME/.xsessionrc" "$HOME/.profile"; do
202+
if ! grep -qF "$COWORK_TAG" "$cowork_file" 2>/dev/null; then
203+
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$cowork_file"
204+
fi
205+
done
206+
mkdir -p "$HOME/.config/environment.d"
207+
cat > "$HOME/.config/environment.d/claude-cowork.conf" <<EOF
208+
${COWORK_TAG}
209+
COWORK_VM_BACKEND=host
210+
EOF
211+
CLAUDE_WRAP_TAG="# managed-by-danger-template: claude-desktop-wrapper"
212+
if [ -x /usr/bin/claude-desktop ] && ! grep -qF "$CLAUDE_WRAP_TAG" /usr/bin/claude-desktop 2>/dev/null; then
213+
if [ ! -x /usr/bin/claude-desktop.real ]; then
214+
sudo cp /usr/bin/claude-desktop /usr/bin/claude-desktop.real
215+
fi
216+
sudo tee /usr/bin/claude-desktop >/dev/null <<EOF
217+
#!/bin/sh
218+
${CLAUDE_WRAP_TAG}
219+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="\${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="\${COWORK_VM_BACKEND:-host}" \
220+
/usr/bin/claude-desktop.real "\$@"
221+
EOF
222+
sudo chmod 0755 /usr/bin/claude-desktop
203223
fi
204224
205225
# Asegurar /home/coder como HOME efectivo incluso si se ejecuta como root

workspaces/Developer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Workspace de desarrollo general, con **Docker in Docker (DinD)**, escritorio XFC
4646
- El daemon Docker se arranca dentro del contenedor (`dockerd` con overlay2) y guarda datos en `/var/lib/docker`.
4747
- Usa KasmVNC para escritorio XFCE (consola del workspace -> abrir URL de KasmVNC).
4848
- El contenedor lleva labels `com.centurylinklabs.watchtower.*` para auto-actualización vía Watchtower.
49+
- Claude Desktop fuerza `COWORK_VM_BACKEND=host` para que el modo cowork no intente usar `bwrap` dentro del contenedor.
4950

5051
### Limitaciones de DinD
5152
- No hay Swarm ni orquestador, por lo que `docker compose` ignora la sección `deploy.*` (incluidos `resources.reservations/limits`, `placement`, `replicas`); solo aplican los flags directos de `docker run`/`docker compose` como `--cpus` o `--memory`.

workspaces/Developer/main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,28 @@ PULSECFG
241241
# COWORK_VM_BACKEND=host evita que Claude Desktop use bwrap (que falla en contenedores)
242242
# El contenedor Docker ya provee el aislamiento necesario
243243
COWORK_TAG="# managed-by-developer-template: cowork-vm-backend"
244-
if ! grep -qF "$COWORK_TAG" "$HOME/.xsessionrc" 2>/dev/null; then
245-
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$HOME/.xsessionrc"
244+
for cowork_file in "$HOME/.xsessionrc" "$HOME/.profile"; do
245+
if ! grep -qF "$COWORK_TAG" "$cowork_file" 2>/dev/null; then
246+
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$cowork_file"
247+
fi
248+
done
249+
mkdir -p "$HOME/.config/environment.d"
250+
cat > "$HOME/.config/environment.d/claude-cowork.conf" <<EOF
251+
${COWORK_TAG}
252+
COWORK_VM_BACKEND=host
253+
EOF
254+
CLAUDE_WRAP_TAG="# managed-by-developer-template: claude-desktop-wrapper"
255+
if [ -x /usr/bin/claude-desktop ] && ! grep -qF "$CLAUDE_WRAP_TAG" /usr/bin/claude-desktop 2>/dev/null; then
256+
if [ ! -x /usr/bin/claude-desktop.real ]; then
257+
sudo cp /usr/bin/claude-desktop /usr/bin/claude-desktop.real
258+
fi
259+
sudo tee /usr/bin/claude-desktop >/dev/null <<EOF
260+
#!/bin/sh
261+
${CLAUDE_WRAP_TAG}
262+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="\${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="\${COWORK_VM_BACKEND:-host}" \
263+
/usr/bin/claude-desktop.real "\$@"
264+
EOF
265+
sudo chmod 0755 /usr/bin/claude-desktop
246266
fi
247267
248268
# Asegurar /home/coder como HOME efectivo incluso si se ejecuta como root

workspaces/DeveloperAndroid/main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,28 @@ PULSECFG
216216
# COWORK_VM_BACKEND=host evita que Claude Desktop use bwrap (que falla en contenedores)
217217
# El contenedor Docker ya provee el aislamiento necesario
218218
COWORK_TAG="# managed-by-android-template: cowork-vm-backend"
219-
if ! grep -qF "$COWORK_TAG" "$HOME/.xsessionrc" 2>/dev/null; then
220-
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$HOME/.xsessionrc"
219+
for cowork_file in "$HOME/.xsessionrc" "$HOME/.profile"; do
220+
if ! grep -qF "$COWORK_TAG" "$cowork_file" 2>/dev/null; then
221+
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$cowork_file"
222+
fi
223+
done
224+
mkdir -p "$HOME/.config/environment.d"
225+
cat > "$HOME/.config/environment.d/claude-cowork.conf" <<EOF
226+
${COWORK_TAG}
227+
COWORK_VM_BACKEND=host
228+
EOF
229+
CLAUDE_WRAP_TAG="# managed-by-android-template: claude-desktop-wrapper"
230+
if [ -x /usr/bin/claude-desktop ] && ! grep -qF "$CLAUDE_WRAP_TAG" /usr/bin/claude-desktop 2>/dev/null; then
231+
if [ ! -x /usr/bin/claude-desktop.real ]; then
232+
sudo cp /usr/bin/claude-desktop /usr/bin/claude-desktop.real
233+
fi
234+
sudo tee /usr/bin/claude-desktop >/dev/null <<EOF
235+
#!/bin/sh
236+
${CLAUDE_WRAP_TAG}
237+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="\${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="\${COWORK_VM_BACKEND:-host}" \
238+
/usr/bin/claude-desktop.real "\$@"
239+
EOF
240+
sudo chmod 0755 /usr/bin/claude-desktop
221241
fi
222242
223243
# Alinear grupos para /dev/kvm sin tocar permisos del host

workspaces/Maker/main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,28 @@ PULSECFG
232232
# COWORK_VM_BACKEND=host evita que Claude Desktop use bwrap (que falla en contenedores)
233233
# El contenedor Docker ya provee el aislamiento necesario
234234
COWORK_TAG="# managed-by-maker-template: cowork-vm-backend"
235-
if ! grep -qF "$COWORK_TAG" "$HOME/.xsessionrc" 2>/dev/null; then
236-
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$HOME/.xsessionrc"
235+
for cowork_file in "$HOME/.xsessionrc" "$HOME/.profile"; do
236+
if ! grep -qF "$COWORK_TAG" "$cowork_file" 2>/dev/null; then
237+
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$cowork_file"
238+
fi
239+
done
240+
mkdir -p "$HOME/.config/environment.d"
241+
cat > "$HOME/.config/environment.d/claude-cowork.conf" <<EOF
242+
${COWORK_TAG}
243+
COWORK_VM_BACKEND=host
244+
EOF
245+
CLAUDE_WRAP_TAG="# managed-by-maker-template: claude-desktop-wrapper"
246+
if [ -x /usr/bin/claude-desktop ] && ! grep -qF "$CLAUDE_WRAP_TAG" /usr/bin/claude-desktop 2>/dev/null; then
247+
if [ ! -x /usr/bin/claude-desktop.real ]; then
248+
sudo cp /usr/bin/claude-desktop /usr/bin/claude-desktop.real
249+
fi
250+
sudo tee /usr/bin/claude-desktop >/dev/null <<EOF
251+
#!/bin/sh
252+
${CLAUDE_WRAP_TAG}
253+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="\${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="\${COWORK_VM_BACKEND:-host}" \
254+
/usr/bin/claude-desktop.real "\$@"
255+
EOF
256+
sudo chmod 0755 /usr/bin/claude-desktop
237257
fi
238258
239259
if [ "${tostring(local.enable_dri)}" = "true" ]; then

workspaces/OpenClaw/main.tf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,28 @@ PULSECFG
173173
# COWORK_VM_BACKEND=host evita que Claude Desktop use bwrap (que falla en contenedores)
174174
# El contenedor Docker ya provee el aislamiento necesario
175175
COWORK_TAG="# managed-by-openclaw-template: cowork-vm-backend"
176-
if ! grep -qF "$COWORK_TAG" "$HOME/.xsessionrc" 2>/dev/null; then
177-
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$HOME/.xsessionrc"
176+
for cowork_file in "$HOME/.xsessionrc" "$HOME/.profile"; do
177+
if ! grep -qF "$COWORK_TAG" "$cowork_file" 2>/dev/null; then
178+
printf '%s\nexport COWORK_VM_BACKEND=host\n' "$COWORK_TAG" >> "$cowork_file"
179+
fi
180+
done
181+
mkdir -p "$HOME/.config/environment.d"
182+
cat > "$HOME/.config/environment.d/claude-cowork.conf" <<EOF
183+
${COWORK_TAG}
184+
COWORK_VM_BACKEND=host
185+
EOF
186+
CLAUDE_WRAP_TAG="# managed-by-openclaw-template: claude-desktop-wrapper"
187+
if [ -x /usr/bin/claude-desktop ] && ! grep -qF "$CLAUDE_WRAP_TAG" /usr/bin/claude-desktop 2>/dev/null; then
188+
if [ ! -x /usr/bin/claude-desktop.real ]; then
189+
sudo cp /usr/bin/claude-desktop /usr/bin/claude-desktop.real
190+
fi
191+
sudo tee /usr/bin/claude-desktop >/dev/null <<EOF
192+
#!/bin/sh
193+
${CLAUDE_WRAP_TAG}
194+
exec env ELECTRON_DISABLE_SANDBOX=1 ELECTRON_OZONE_PLATFORM_HINT="\${ELECTRON_OZONE_PLATFORM_HINT:-auto}" COWORK_VM_BACKEND="\${COWORK_VM_BACKEND:-host}" \
195+
/usr/bin/claude-desktop.real "\$@"
196+
EOF
197+
sudo chmod 0755 /usr/bin/claude-desktop
178198
fi
179199
180200
# Asegurar /home/coder como HOME efectivo incluso si se ejecuta como root

0 commit comments

Comments
 (0)