Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- c++ 정규식
- regex_search
- CentOS7
- 백준
- c3 축 없애기
- selinux port 등록
- c3 step graph
- 정규식 활용
- 정규식 문자열 출력
- python os
- 정규식 컴파일
- c3 축 가리기
- g++ 업데이트
- telegraf
- c3 초
- InfluxDB
- c3 second
- subporcess path
- snmp
- grafana dashboard
- snmp test
- gcc 업데이트
- influxdb 설치
- linux시간으로 변경
- python subprocess
- semanage
- centos pyhon 설치
- python popen
- 1697
- gcc regex
Archives
- Today
- Total
리셋 되지 말자
[buildx] buildx 사용하기 - volume 마운트 실행 본문
사용
buildx builder 컨테이너를 생성할 때, 아래 명령어를 이용하여 생성할 수 있다.
docker buildx create --name builder --use --bootstrap
위의 명령어를 사용하여 생성하면 원하는 vloume을 마운트 하는게 불가능해서 약간 편법을 이용하기로 한다. 먼저 아래의 내용을 builder
라는 이름으로 $HOME/.docker/buildx/instances
경로에 저장한다.
{"Name":"builder","Driver":"docker-container","Nodes":[{"Name":"builder0","Endpoint":"unix:///var/run/docker.sock","Platforms":null,"Flags":null,"DriverOpts":null,"Files":null}],"Dynamic":false}
그리고 buildx 컨테이너를 생성한다.
mkdir $HOME/volume
docker run -d -v $HOME/volume:/var/lib/buildkit --privileged --name buildx_buildkit_builder0 moby/buildkit:buildx-stable-1
컨테이너가 생성되면, 아래 명령어로 buildx builder를 기본 builder로 지정한다.
docker buildx use builder
docker buildx ls
NAME/NODE DRIVER/ENDPOINT STATUS BUILDKIT PLATFORMS
builder * docker-container
builder0 unix:///var/run/docker.sock running v0.10.5 linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/amd64/v4, linux/386
default docker
default default running 20.10.17 linux/amd64, linux/386
volume 보존 테스트
위에서 $HOME/volume
디렉토리를 마운트한 뒤, builder 컨테이너를 삭제한 뒤에 다시 생성해도 빌드캐시가 유지되는지 테스트 해본다. 먼저 Dockerfile을 임시로 빌드한다. Dockerfile 내용은 아래와 같다.
FROM python:3.7
ENV PYTHONUNBUFFERED 1
ENV PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION python
RUN mkdir /home/ubuntu
WORKDIR /home/ubuntu
RUN apt-get update && apt-get install -y libgl1-mesa-dev
RUN pip install Tensorflow==2.2
RUN pip install opencv-python==4.5.1.48
Dockerfile을 builder를 이용해서 빌드한다.
docker buildx build .
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 237.1s (9/9) FINISHED
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 361B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.7 3.4s
=> [1/6] FROM docker.io/library/python:3.7@sha256:bf85a74f4ace82f3503c2199aaae10e7a8e370bc7 60.7s
=> => resolve docker.io/library/python:3.7@sha256:bf85a74f4ace82f3503c2199aaae10e7a8e370bc7e 0.0s
=> => sha256:9a5f30b220ac2d88165d2e71dec428a6846050e24b4a8cedb8c1d90b46780cc 2.89MB / 2.89MB 0.7s
=> => sha256:24e64f2eb9381ce66436fa7d151419d087b854b218c6abc2e0e94915c00fc 15.48MB / 15.48MB 3.8s
=> => sha256:ece0ca00f21cd46fbcf08f8172c1b8d9be5d9c68f3a53e107279a31ee30bba2e 234B / 234B 0.5s
=> => sha256:0f67f32c26d393a2580062f2cebfde80cc4c5a5e264bbb7a32569c6c7551c1c 6.29MB / 6.29MB 4.3s
=> => sha256:60b38700e7fb2cdfac79b15e4c1691a80fe6b4101c7b7fea66b9e7cd64 196.88MB / 196.88MB 35.5s
=> => sha256:81283a9569ad5e90773f038daedd0d565810ca5935eec8f53b8bcb6a1990 54.58MB / 54.58MB 21.4s
=> => sha256:c796299bbbddc7aeada9539a4e7874a75fa2b6ff421f8d5ad40f227b40ab4 10.88MB / 10.88MB 3.6s
=> => sha256:fa1d4c8d85a4e064e50cea74d4aa848dc5fc275aef223fcc1f21fbdb1b5dd18 5.16MB / 5.16MB 2.3s
=> => sha256:32de3c850997ce03b6ff4ae8fb00b34b9d7d7f9a35bfcdb8538e22cc7b77 55.03MB / 55.03MB 16.4s
=> => extracting sha256:32de3c850997ce03b6ff4ae8fb00b34b9d7d7f9a35bfcdb8538e22cc7b77c29d 1.8s
=> => extracting sha256:fa1d4c8d85a4e064e50cea74d4aa848dc5fc275aef223fcc1f21fbdb1b5dd182 0.2s
=> => extracting sha256:c796299bbbddc7aeada9539a4e7874a75fa2b6ff421f8d5ad40f227b40ab4d86 0.2s
=> => extracting sha256:81283a9569ad5e90773f038daedd0d565810ca5935eec8f53b8bcb6a199030d6 6.6s
=> => extracting sha256:60b38700e7fb2cdfac79b15e4c1691a80fe6b4101c7b7fea66b9e7cd64d961cf 12.5s
=> => extracting sha256:0f67f32c26d393a2580062f2cebfde80cc4c5a5e264bbb7a32569c6c7551c1c2 11.2s
=> => extracting sha256:24e64f2eb9381ce66436fa7d151419d087b854b218c6abc2e0e94915c00fc4bd 0.5s
=> => extracting sha256:ece0ca00f21cd46fbcf08f8172c1b8d9be5d9c68f3a53e107279a31ee30bba2e 0.1s
=> => extracting sha256:9a5f30b220ac2d88165d2e71dec428a6846050e24b4a8cedb8c1d90b46780cce 0.2s
=> [2/6] RUN mkdir /home/ubuntu 3.0s
=> [3/6] WORKDIR /home/ubuntu 0.2s
=> [4/6] RUN apt-get update && apt-get install -y libgl1-mesa-dev 18.8s
=> [5/6] RUN pip install Tensorflow==2.2 138.6s
=> [6/6] RUN pip install opencv-python==4.5.1.48 12.2s
이 상태에서 builder를 제거한 뒤 동일한 볼륨을 마운트하여 다시 builder를 생성한다.
docker buildx rm builder
builder removed
echo '{"Name":"builder","Driver":"docker-container","Nodes":[{"Name":"builder0","Endpoint":"unix:///var/run/docker.sock","Platforms":null,"Flags":null,"DriverOpts":null,"Files":null}],"Dynamic":false}' > .docker/buildx/instances/builder
docker run -d -v $HOME/volume:/var/lib/buildkit --privileged --name buildx_buildkit_builder0 moby/buildkit:buildx-stable-1
0609d310445aab9309f5b3f3fda9dd0b70fba476cf770a4596f8015378c303ef
이제 동일한 Dockerfile로 빌드를 해서 빌드캐시가 잘 동작하는지 확인한다.
docker buildx build .
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
[+] Building 11.0s (9/9) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 361B 0.0s
=> [internal] load metadata for docker.io/library/python:3.7 1.9s
=> [1/6] FROM docker.io/library/python:3.7@sha256:bf85a74f4ace82f3503c2199aaae10e7a8e370bc7e 0.0s
=> => resolve docker.io/library/python:3.7@sha256:bf85a74f4ace82f3503c2199aaae10e7a8e370bc7e 0.0s
=> CACHED [2/6] RUN mkdir /home/ubuntu 0.0s
=> CACHED [3/6] WORKDIR /home/ubuntu 0.0s
=> CACHED [4/6] RUN apt-get update && apt-get install -y libgl1-mesa-dev 0.0s
=> CACHED [5/6] RUN pip install Tensorflow==2.2 0.0s
=> [6/6] RUN pip install opencv-python==4.5.1.48 9.0s
'Docker' 카테고리의 다른 글
Minio 사용해보기 (0) | 2024.02.25 |
---|---|
[buildx] buildx 사용하기 - 설치 (0) | 2023.01.06 |
docker image 실제 크기 (0) | 2022.02.10 |
[source code] build 코드 (0) | 2021.12.03 |
[docker] docker logs -f <컨테이너명> (0) | 2021.07.14 |
Comments