Podman으로 작업하기

Sharing files between a container and the host Btrfs filesystem#

참고

이 메서드는 Btrfs와 같이 Podman이 지원하는 copy-on-write 파일 시스템에서만 작동합니다. Ext4와 같은 다른 파일 시스템의 경우 pnpm이 대신 파일을 복사합니다.

Podman은 Btrfs와 같은 copy-on-write 파일 시스템을 지원합니다. Btrfs를 사용하면 컨테이너 런타임이 마운트된 볼륨에 대한 실제 Btrfs 하위 볼륨을 생성합니다. pnpm can use this behavior to reflink the files between different mounted volumes.

호스트와 컨테이너 간에 파일을 공유하려면, 호스트의 스토어 디렉터리와 node_modules 디렉터리를 컨테이너에 마운트하세요. 이를 통해 컨테이너 내부의 pnpm은 호스트의 파일을 reflink로 자연스럽게 재사용할 수 있습니다.

important

신뢰할 수 있는 컨테이너에만 호스트의 pnpm 스토어를 마운트하세요. 마운트된 스토어에 쓰기 권한이 있는 컨테이너는 해당 스토어를 재사용하는 이후 설치에 영향을 줄 수 있습니다.

아래는 데모를 위한 컨테이너 설정의 예시입니다:

Declare Node.js in devEngines.runtime in your package.json. The pnpm install command below will install the declared version automatically.

Dockerfile
FROM ghcr.io/pnpm/pnpm:11

WORKDIR /app

VOLUME [ "/pnpm-store", "/app/node_modules" ]
RUN pnpm config --global set store-dir /pnpm-store

# You may need to copy more files than just package.json in your code
COPY package.json /app/package.json

RUN pnpm install
RUN pnpm run build

다음 명령을 실행하여 podman 이미지를 빌드합니다:

podman build . --tag my-podman-image:latest -v "$HOME/.local/share/pnpm/store:/pnpm-store" -v "$(pwd)/node_modules:/app/node_modules"