컨테이너 보안(Docker/Kubernetes)
이미지 검사와 네트워크 정책을 포함하여 Docker와 Kubernetes로 컨테이너화된 애플리케이션을 빌드, 배포, 관리하는 안전한 방식을 구현합니다.
컨테이너 보안(Docker/Kubernetes)은(는) CoddyKit의 무료 Secure Coding & OWASP Top 10 for Backend 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Secure Coding & OWASP Top 10 for Backend 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Secure Coding & OWASP Top 10 for Backend 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Introduction to Container Security
Welcome to Container Security! Here, we'll explore how to protect your applications when they run inside containers like Docker and are orchestrated by systems like Kubernetes.
Containers offer great flexibility and efficiency, but they also introduce new security challenges that need careful attention.
Minimize Container Images
Smaller container images mean less attack surface. Remove unnecessary tools, libraries, and files from your final image.
Using multi-stage builds and minimal base images (like Alpine Linux variants) are excellent strategies.
FROM openjdk:17-jdk-slim AS builder
WORKDIR /app
COPY . .
RUN javac Main.java
FROM openjdk:17-jre-slim
WORKDIR /app
COPY --from=builder /app/Main.class .
CMD ["java", "Main"]Use Trusted Base Images
Always start with official and well-maintained base images from trusted registries. Unofficial images might contain vulnerabilities or even malicious code.
- Verify sources: Only pull images from reputable vendors or official repositories.
- Scan regularly: Even official images can have vulnerabilities; scan them often.
Principle of Least Privilege
Run your containers with the minimum necessary permissions. This limits the damage if a container is compromised.
- Run as non-root: Avoid running processes as the root user inside the container.
- Drop capabilities: Remove Linux capabilities (e.g.,
NET_ADMIN,SYS_ADMIN) that your application doesn't need.
docker run --user 1000:1000 \
--cap-drop=ALL \
my-secure-appScan Container Images for Vulnerabilities
Integrate automated image scanning tools (like Trivy, Clair, or vulnerability scanners from cloud providers) into your CI/CD pipeline.
Scan images early and often to detect known vulnerabilities in your dependencies and operating system layers before deployment.
Kubernetes Network Policies
Network Policies in Kubernetes allow you to control which pods can communicate with each other and with external network endpoints.
By default, pods can communicate freely. Network policies enforce segmentation, creating a firewall around your pods.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: deny-all-ingress
namespace: default
spec:
podSelector: {}
policyTypes:
- IngressSecure Secrets Management
Sensitive information like API keys, database passwords, and private certificates should never be hardcoded into images or configuration files.
Use Kubernetes Secrets, HashiCorp Vault, or cloud-specific secret managers to store and inject secrets securely at runtime.
apiVersion: v1
kind: Secret
metadata:
name: my-app-secret
type: Opaque
data:
api_key: YmFzZTY0ZW5jb2RlZHNlY3JldA== # base64 encoded value
db_password: cGFzc3dvcmQ=Runtime Security & Monitoring
Even with robust build-time security, runtime protection is crucial. Monitor container behavior for suspicious activities.
Tools like Falco can detect anomalous process execution, unauthorized file access, or unexpected network connections within your containers.
Kubernetes Security Contexts
Security Contexts in Kubernetes allow you to define privilege and access control settings for a Pod or Container.
You can specify settings like running as a non-root user, dropping Linux capabilities, or configuring SELinux/AppArmor profiles.
apiVersion: v1
kind: Pod
metadata:
name: secure-pod
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 2000
containers:
- name: my-container
image: my-image
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]Quick Check: Image Security
Which of the following are best practices for securing container images?
Container Security Recap
In this lesson, we covered key aspects of securing containerized applications:
- Minimizing image size and using trusted base images.
- Applying the principle of least privilege.
- Regularly scanning images for vulnerabilities.
- Controlling network access with Kubernetes Network Policies.
- Managing secrets securely.
- Monitoring containers at runtime for suspicious activity.
- Enforcing security settings with Kubernetes Security Contexts.
By following these practices, you can significantly enhance the security posture of your Docker and Kubernetes deployments.
자주 묻는 질문
“컨테이너 보안(Docker/Kubernetes)” 강의는 무료인가요?
네 — “컨테이너 보안(Docker/Kubernetes)” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Secure Coding & OWASP Top 10 for Backend 강의 전체를 잠금 해제할 수 있습니다. Secure Coding & OWASP Top 10 for Backend 강의에는 총 4개의 강의가 포함되어 있습니다.
“컨테이너 보안(Docker/Kubernetes)”에서 뭘 배우나요?
이미지 검사와 네트워크 정책을 포함하여 Docker와 Kubernetes로 컨테이너화된 애플리케이션을 빌드, 배포, 관리하는 안전한 방식을 구현합니다. 브라우저에서 직접 실행하는 실습 코드로 Secure Coding & OWASP Top 10 for Backend을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Secure Coding & OWASP Top 10 for Backend을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Secure Coding & OWASP Top 10 for Backend은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“컨테이너 보안(Docker/Kubernetes)” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Secure Coding & OWASP Top 10 for Backend 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Secure Coding & OWASP Top 10 for Backend 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- 안전한 클라우드 배포(AWS/Azure/GCP)
- 컨테이너 보안(Docker/Kubernetes)
- 서버리스 보안 모범 사례
- 코드형 인프라 보안