Showing posts with label container. Show all posts
Showing posts with label container. Show all posts

Thursday, April 23, 2026

在 WSL + Podman 環境使用 Visual Studio Code Dev Containers

首先需要啟用 podman.socket: systemctl --user enable --now podman.socket

接著需要設定調整幾個 VS Code 的設定:

dev.containers.dockerPath
podman
dev.containers.dockerSocketPath
/run/user/1000/podman/podman.sock

這樣通訊是會過兩層,從 Windows 到 WSL 再到 DevContainer 內,操作時體感上反應會稍微頓一點,啟動也會花比較多時間。此外,很多 VScode extensions 也得多裝進去 devcontainer 裡頭才能使用。

如果 .devcontainer/devcontainer.json 沒有用到 compose 的話,似乎沒有設定 compose 的程式路徑也沒有關係。

Ref:

Monday, May 16, 2022

Podman 清除建置失敗的殘餘容器資料

使用 podman build 建置容器時,建置失敗的中間容器會被留下來,而且不會被 podman system prune -a 清除。

$ podman system prune -a
WARNING! This command removes:
	- all stopped containers
	- all networks not used by at least one container
	- all images without at least one container associated with them
	- all build cache

Are you sure you want to continue? [y/N] y
Error: Image used by fbcfbb...7e8: image is in use by a container

這個原因看起來是因為 podman system prune 清除的對象是 Podman 本身產生的資料,而 podman build 背後是透過 Buildah 來進行建置,而這部份就不被認為是 Podman 的直接行為。細節可以參考在 #7889 Failed to remove image, image is in use by container 這個 Issue 裡的描述。

處理的方式就是手動刪除,先執行 podman ps --all --storage 把所有的容器列出來,再用 podman rm 刪掉。

$ podman ps --all --storage
CONTAINER ID  IMAGE                                      COMMAND     CREATED      STATUS      PORTS       NAMES
b396d84310a4  docker.io/library/ubuntu:16.04             buildah     10 days ago  storage                 ubuntu-working-container
fbcfbbc3c233  docker.io/library/bd7139...bed-tmp:latest  buildah     10 days ago  storage                 793b78...79a-working-container
$ podman rm b396d84310a4 fbcfbbc3c233