본문 바로가기
C.W.K.
Stream
Lesson 08 of 10 · published

sandbox 컨테이너

~16 min · gemini, sandbox, container, docker

Level 0🌱 입문자
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

Gemini는 실제 container 안에서 에이전트를 격리해

--sandbox를 켜면 Gemini는 작업 디렉터리를 Docker나 Podman container 안에 넣고 에이전트를 실행해. 안에서는 파일을 바꿀 수 있지만 작업 공간 밖의 /etc~/.ssh에는 닿지 못하고, 변경은 세션 종료나 명시적인 시점에 되돌려 반영돼.

정책 기반 경계보다 준비는 무거워. container 실행 환경이 필요하고 시작 비용도 들지만 커널이 실제로 격리를 강제해. 읽기 전용 감사라면 -e "WriteFile,RunShellCommand"처럼 container 안에서도 특정 도구를 꺼.

자주 쓴다면 git, ripgrep, jq, Python 같은 표준 도구를 넣은 이미지를 미리 만들어. 매번 설치하는 시간은 줄이고, 강한 격리는 그대로 유지할 수 있어.

직접 확인할 항목: -e, gemini --sandbox -e "WriteFile,RunShellCommand".

Code

sandbox에서 실행하기·bash
# Default — no sandbox, agent runs in your shell
gemini

# Sandbox — Docker container
gemini --sandbox

# With tool exclusions even inside the sandbox
gemini --sandbox -e "WriteFile,RunShellCommand"

# Check container status
docker ps --filter "label=gemini.session"

# Configure default in settings
# ~/.gemini/settings.json
{ "sandbox": { "default": true, "image": "gemini-sandbox:latest" } }
사용자 정의 sandbox Dockerfile·dockerfile
FROM node:20-slim

# Pre-install tools the agent might need
RUN apt-get update && apt-get install -y --no-install-recommends \
      git curl ripgrep jq python3 \
    && rm -rf /var/lib/apt/lists/*

# Pre-install Gemini's expected runtime
RUN npm install -g @google/gemini-cli

# Non-root user for additional safety
RUN useradd -m -s /bin/bash agent
USER agent
WORKDIR /workspace

ENTRYPOINT ["gemini"]

External links

Exercise

sandbox 컨테이너 안에서 Gemini 세션을 실행해. ~/.ssh에 파일을 쓰거나 /etc를 수정하는 파괴적 작업을 시도해서 차단되는지 확인해봐. 그런 다음 평소 필요한 도구를 넣은 사용자 정의 sandbox 이미지를 만들어.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.