# Docker & Containerization (Go) > Dockerfile, 멀티 스테이지 빌드, 이미지 최적화, docker-compose, 컨테이너 오케스트레이션 - 20 면접 질문 - Senior - [면접 질문: Go](https://sharpskill.dev/ko/technologies/go/interview-questions.md) ## 1. Go 애플리케이션에서 멀티 스테이지 빌드를 사용하는 주된 이유는 무엇입니까? **답변** 멀티 스테이지 빌드는 컴파일 환경을 최종 이미지에서 분리합니다. 빌드 스테이지에는 전체 Go SDK(수백 MB)가 포함되지만 최종 이미지에는 컴파일된 바이너리만 포함됩니다. 이를 통해 이미지 크기가 크게 줄어들고(약 800MB에서 수 MB로) 프로덕션에서 불필요한 빌드 도구를 제거하여 공격 표면을 최소화합니다. ## 2. 크기와 공격 표면을 최소화하기 위해 프로덕션 Go 애플리케이션에 권장되는 베이스 이미지는 무엇입니까? **답변** scratch 이미지는 운영체제가 없는 빈 이미지입니다. Go는 libc나 다른 시스템 의존성이 필요 없는 정적 바이너리로 컴파일되므로 scratch를 사용할 수 있습니다. 이는 가능한 가장 작은 이미지(수 MB)를 생성하며, 악용 가능한 도구나 셸이 없기 때문에 최고의 보안을 제공합니다. distroless와 alpine은 유효하지만 덜 최적화된 대안입니다. ## 3. scratch 이미지와 호환되는 바이너리를 만들기 위해 필요한 Go 컴파일 플래그는 무엇입니까? **답변** CGO_ENABLED=0은 cgo를 비활성화하여 Go가 net 및 os/user 같은 패키지에 대해 순수 Go 구현을 사용하도록 강제합니다. 이것이 없으면 바이너리는 libc에 대한 동적 의존성을 갖게 됩니다. GOOS와 GOARCH는 대상 플랫폼을 지정합니다. 이러한 플래그를 결합하면 외부 의존성이 없는 완전한 정적 바이너리가 생성되어 scratch에 이상적입니다. ## 17개 추가 질문 이용 가능 - Go 애플리케이션을 빌드할 때 Docker 레이어 캐싱을 어떻게 최적화합니까? - scratch와 비교했을 때 Go에 Google Distroless 이미지를 사용하는 이점은 무엇입니까? 무료로 가입하기: https://sharpskill.dev/ko/login ## 기타 Go 면접 주제 - [Go 기초](https://sharpskill.dev/ko/technologies/go/interview-questions/go-basics.md): 25개 질문, Junior - [Go 데이터 구조](https://sharpskill.dev/ko/technologies/go/interview-questions/go-data-structures.md): 20개 질문, Junior - [Go 인터페이스](https://sharpskill.dev/ko/technologies/go/interview-questions/go-interfaces.md): 18개 질문, Junior - [에러 처리](https://sharpskill.dev/ko/technologies/go/interview-questions/error-handling.md): 20개 질문, Junior - [Goroutine 기초](https://sharpskill.dev/ko/technologies/go/interview-questions/goroutines-basics.md): 20개 질문, Junior - [Channels](https://sharpskill.dev/ko/technologies/go/interview-questions/channels.md): 22개 질문, Junior - [Go Modules](https://sharpskill.dev/ko/technologies/go/interview-questions/go-modules.md): 18개 질문, Mid-Level - [HTTP 서버](https://sharpskill.dev/ko/technologies/go/interview-questions/http-server.md): 24개 질문, Mid-Level - [HTTP 클라이언트](https://sharpskill.dev/ko/technologies/go/interview-questions/http-client.md): 18개 질문, Mid-Level - [JSON 인코딩](https://sharpskill.dev/ko/technologies/go/interview-questions/json-encoding.md): 20개 질문, Mid-Level - [Database/SQL](https://sharpskill.dev/ko/technologies/go/interview-questions/database-sql.md): 22개 질문, Mid-Level - [context 패키지](https://sharpskill.dev/ko/technologies/go/interview-questions/context-package.md): 20개 질문, Mid-Level - [Testing](https://sharpskill.dev/ko/technologies/go/interview-questions/testing.md): 22개 질문, Mid-Level - [동시성 패턴](https://sharpskill.dev/ko/technologies/go/interview-questions/concurrency-patterns.md): 24개 질문, Mid-Level - [동기화 프리미티브](https://sharpskill.dev/ko/technologies/go/interview-questions/sync-primitives.md): 22개 질문, Mid-Level - [Go 웹 프레임워크](https://sharpskill.dev/ko/technologies/go/interview-questions/go-web-frameworks.md): 20개 질문, Mid-Level - [REST API 설계](https://sharpskill.dev/ko/technologies/go/interview-questions/rest-api-design.md): 20개 질문, Mid-Level - [gRPC](https://sharpskill.dev/ko/technologies/go/interview-questions/grpc.md): 22개 질문, Mid-Level - [Reflection](https://sharpskill.dev/ko/technologies/go/interview-questions/reflection.md): 20개 질문, Senior - [메모리 관리](https://sharpskill.dev/ko/technologies/go/interview-questions/memory-management.md): 24개 질문, Senior - [성능 최적화](https://sharpskill.dev/ko/technologies/go/interview-questions/performance-optimization.md): 22개 질문, Senior - [Generics](https://sharpskill.dev/ko/technologies/go/interview-questions/generics.md): 20개 질문, Senior - [Go Design Patterns](https://sharpskill.dev/ko/technologies/go/interview-questions/design-patterns.md): 24개 질문, Senior - [Microservices](https://sharpskill.dev/ko/technologies/go/interview-questions/microservices.md): 24개 질문, Senior - [보안 및 인증](https://sharpskill.dev/ko/technologies/go/interview-questions/security-authentication.md): 24개 질문, Senior - [Kubernetes Basics](https://sharpskill.dev/ko/technologies/go/interview-questions/kubernetes-basics.md): 22개 질문, Senior - [고급 Go](https://sharpskill.dev/ko/technologies/go/interview-questions/advanced-go.md): 20개 질문, Senior - [CLI 개발](https://sharpskill.dev/ko/technologies/go/interview-questions/cli-development.md): 20개 질문, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ko/technologies/go/interview-questions/docker-containerization