개발일지/Docker

[Docker] dockerignore 파일

양쏘쏘 2024. 6. 10. 13:21
728x90
반응형

Git에서 gitignore 파일을 통해 깃에 올리지 않는 파일을 정의하듯이 Docker에서 dockerignore파일을 만들 수 있습니다.

Docs에 따르면 .dockerignore 파일을 통해 빌드되지 않았으면 좋겠는 파일이나 디렉토리를 설정할 수 있고

이를 통해 빌드 속도 향상시킬 수 있다고 합니다. 

그리고 당연하게도 Docker image 사이즈를 줄일 수 있고 보안적인 문제 또한 고려하면 필수적인 설정입니다. 

 

작성 예시

# .git관련 파일 무시
.git
.gitignore

# 모든 폴더안에 있는 *.class 파일들을 무시
**/*.class

# 모든 마크다운 파일들 (md) 파일들을 무시,
*.md

.dockerignore 적용예시

.dockerignore 파일이 잘 생성된다면 build 과정에서 이렇게 나오는 것을 확인하실 수 있습니다. 

 

[학습 출처]

 

Build context

Learn how to use the build context to access files from your Dockerfile

docs.docker.com

 

How to use .dockerignore and its importance | Shisho Cloud | Shisho Cloud

This article provides an overview of .dockerignore files, their benefits, syntax and real-world examples.

shisho.dev

 

728x90

'개발일지 > Docker' 카테고리의 다른 글

[Jenkins] Docker에 Jenkins 세팅하기  (0) 2024.06.25
[Docker] Spring Boot Docker 배포  (1) 2024.06.10