SlideShare a Scribd company logo
정찬민
Docker Custom Image
목차
• Docker
• VM 과의 차이
• Docker Image
• command
• Make Custom Image
Docker
• 컨테이너 기반의 오픈 소스 가상화 플랫폼
• 애플리케이션을 신속하게 구축, 테스트 및 배
포 가능
• 컨테이너에는 라이브러리, 시스템 도구, 코드,
런타임 등 소프트웨어를 실행하는 데 필요한
모든 것이 포함
• 환경에 구애 받지 않고 애플리케이션을 신속
하게 배포 및 확장
VM 과의 차이
• OS+APP+LIB 로 구성된 VM 과는 달리 Docker 는 APP+LIB 만 설치
• OS 자원은 Host OS 와 공유
[VM] [Docker]
가상 머신에 비해 경량화가 가능하며 빠른 처리 속도
Docker Image
[Docker hub] [Docker host]
image
pull
• Docker 컨테이너를 만들기 위한 템플릿
• 이미지는 컨테이너 실행에 필요한 파일 시스템, 라이브러리, 설정 정보등을 포함
• 같은 이미지에서 여러 개의 컨테이너를 실행할 수 있고 컨테이너가 변해도 이미지 고정
Command
• docker run – docker image 로 컨테이너 생성
docker run -d -it --name <docker image 이름> < docker hub reference image>
• docker exec – 로컬에서 docker 컨테이너 안의 명령을 실행
docker exec -it <CONTAINER ID> <shell>
• docker tag – docker hub 에 이미지를 업로드 하기 위해서는 tag 설정
docker tag <IMAGE> <저장소>/<image 이름>:<버전>
• docker push – docker image 를 docker hub 에 업로드
docker push <저장소>/<image 이름>:<버전>
docker push <docker hub 계정>/<image 이름>:<버전>
• docker commit – 컨테이너 생성 이후 변경 사항을 docker image 에 업로드
docker commit <CONTAINER ID> <image 이름>:<버전>
Command
• docker cp – docker 컨테이너와 로컬과의 파일 복사
docker cp <로컬 파일 명> <CONTAINER ID>:<저장 위치>
docker cp <CONTAINER ID>:<저장 위치> <로컬 파일 명>
Make Custom Image
• APP : python 3.8 – Miniconda3
• APP : java8.0 - openjdk
• 고객사 APP 실행 시 필요 library 설치
ubuntu 18.04
+ miniconda3
+ library
ubuntu 18.04
+ miniconda
ubuntu 18.04
+ miniconda
+ library
Dockertest:0.1 Dockertest:0.2 Dockertest:0.3
+ jdk
Make Custom Image
• docker hub 를 통해 ubuntu18.04 image 로 docker 컨테이너 생성
docker run -d -it --name dockertest ubuntu:18.04
root@bizz:/home/bizz# docker run -d -it --name dockertest ubuntu:18.04
Unable to find image 'ubuntu:18.04' locally
18.04: Pulling from library/ubuntu
f08d8e2a3ba1: Pull complete
3baa9cb2483b: Pull complete
94e5ff4c0b15: Pull complete
1860925334f9: Pull complete
Digest: sha256:05a58ded9a2c792598e8f4aa8ffe300318eac6f294bf4f49a7abae7544918592
Status: Downloaded newer image for ubuntu:18.04
c9a417d374a292db4caebe55abd890986e5a6ca8fc4aba301c8ca058cce8e154
root@bizz:/home/bizz# ls
miniconda3 miniconda3_edit.tar.gz miniconda3.tar.gz mount snap
root@bizz:/home/bizz# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9a417d374a2 ubuntu:18.04 "/bin/bash" 56 seconds ago Up 52 seconds dockertest
Make Custom Image
• ubuntu 에 miniconda3 설치
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
root@c9a417d374a2:/# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
--2020-08-29 07:26:10-- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8303, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 93052469 (89M) [application/x-sh]
Saving to: 'Miniconda3-latest-Linux-x86_64.sh'
Miniconda3-latest-Linux-x86_64.sh
100%[===================================================================================================
=====================================>] 88.74M 10.9MB/s in 9.8s
2020-08-29 07:26:19 (9.04 MB/s) - 'Miniconda3-latest-Linux-x86_64.sh' saved [93052469/93052469]
root@c9a417d374a2:/# bash Miniconda3-latest-Linux-x86_64.sh
<생략>
Thank you for installing Miniconda3!
root@c9a417d374a2:/#
• docker 컨테이너 접속
docker exec –it c9a417d374a2 bash
root@bizz:/home/bizz# docker exec -it c9a417d374a2 bash
root@c9a417d374a2:/#
Make Custom Image
• 1차 이미지 배포
docker commit c9a417d374a2 docker_custom_image:0.1
docker tag docker_custom_image:0.1 jcm9812/docker_custom_image:0.1
docker push jcm9812/docker_custom_image:0.1
root@bizz:/home/bizz# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9a417d374a2 ubuntu:18.04 "/bin/bash" 26 minutes ago Up 26 minutes dockertest
root@bizz:/home/bizz# docker commit c9a417d374a2 docker_custom_image:0.1
sha256:61362b1e924abe4b1384503ce503a9956b3a915e06a66a247e79eff11e4cce25
root@bizz:/home/bizz# docker tag docker_custom_image:0.1 jcm9812/docker_custom_image:0.1
root@bizz:/home/bizz# docker push jcm9812/docker_custom_image:0.1
The push refers to repository [docker.io/jcm9812/docker_custom_image]
e335ccd7dfd0: Pushed
001e4a80973b: Layer already exists
2ba5b91ca2b0: Layer already exists
2f37d1102187: Layer already exists
79bde4d54386: Layer already exists
0.1: digest: sha256:f90857818af46db53efbb9ea312dbdd169984db7a14432cbeee3082fd942e1a9 size: 1365
root@bizz:/home/bizz#
Make Custom Image
• 1차 배포 이미지 로 docker 컨테이너 생성
docker run -d -it jcm9812/docker_custom_image:0.1 - local 에 docker image 가 없을 경우
docker run -d -it docker_custom_image:0.1 - local 에 docker image 가 있을 경우
root@bizz:/home/bizz# docker run -d -it jcm9812/docker_custom_image:0.1
010fecc8215a38ce3cedca84388e2ac4948e609777bb6d32d5d1f15ea7cd0105
root@bizz:/home/bizz# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" 4 seconds ago Up 2 seconds great_ramanujan
c9a417d374a2 ubuntu:18.04 "/bin/bash" 2 hours ago Up 2 hours dockertest
root@bizz:/tmp# docker cp numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl 010fecc8215a:/tmp
root@bizz:/tmp# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" 53 minutes ago Up 53 minutes great_ramanujan
c9a417d374a2 ubuntu:18.04 "/bin/bash" 2 hours ago Up 2 hours
root@bizz:/tmp# docker exec -it 010fecc8215a bash
(base) root@010fecc8215a:/# ls /tmp/
numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl
(base) root@010fecc8215a:/#
• 라이브러리 컨테이너에 복사(ex : numpy-1.19.1 )
docker cp numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl 010fecc8215a:/tmp
docker exec –it 010fecc8215a bash
Make Custom Image
• 필요 라이브 러리 및 패키지 설치
/root/miniconda3/bin/python -m pip install /tmp/ tmp/numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl
(base) root@010fecc8215a:/# /root/miniconda3/bin/python -m pip install /tmp/numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl
Processing /tmp/numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.19.1
(base) root@010fecc8215a:/#
Make Custom Image
• 2차 이미지 빌드
docker commit 010fecc8215a docker_custom_image:0.2
docker tag docker_custom_image:0.1 jcm9812/docker_custom_image:0.2
docker push jcm9812/docker_custom_image:0.2
root@bizz:/tmp# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" About an hour ago Up About an hour great_ramanujan
c9a417d374a2 ubuntu:18.04 "/bin/bash" 3 hours ago Up 3 hours dockertest
root@bizz:/tmp# docker commit 010fecc8215a docker_custom_image:0.2
sha256:ad641601e269ac243db4f634fa7c3327e4c1e4d1377870ec574b7194ec141756
root@bizz:/tmp# docker tag docker_custom_image:0.2 jcm9812/docker_custom_image:0.2
root@bizz:/tmp# docker push jcm9812/docker_custom_image:0.2
The push refers to repository [docker.io/jcm9812/docker_custom_image]
897b94cf4ef6: Pushed
e335ccd7dfd0: Layer already exists
001e4a80973b: Layer already exists
2ba5b91ca2b0: Layer already exists
2f37d1102187: Layer already exists
79bde4d54386: Layer already exists
0.2: digest: sha256:f1da086d73933235864ae1134290dcfdac69dd8faa049426251b5ba154f47319 size: 1577
Make Custom Image
• 최종 이미지 배포(Dockerfile) - Docker image 생성을 위한 스크립트
# docker image load
FROM jcm9812/docker_custom_image:0.2
# docker image load
COPY --from=openjdk:8-alpine / /
# 내부 명령어 실행
RUN /root/miniconda3/bin/python -version
# home directory 설정
WORKDIR /home/bizz
# 내부 명령어 실행
RUN ["/bin/bash", "-c", "java -version"]
Dockerfile
▪ Docker image 생성을 위한 스크립트 파일
▪ Docker exec / 설치 / commit 의 일괄 작업의 스크립팅
▪ docker hub 로 부터 1개 이상의 docker image 사용 가능
Make Custom Image
• 최종 이미지 배포
root@bizz:/tmp# docker build -t jcm9812/docker_custom_image .
Sending build context to Docker daemon 13.35MB
Step 1/5 : FROM jcm9812/docker_custom_image:0.2
0.2: Pulling from jcm9812/docker_custom_image
Digest: sha256:f1da086d73933235864ae1134290dcfdac69dd8faa049426251b5ba154f47319
Status: Downloaded newer image for jcm9812/docker_custom_image:0.2
---> ad641601e269
Step 2/5 : COPY --from=openjdk:8-alpine / /
---> Using cache
---> daffe858dbdd
Step 3/5 : RUN /root/miniconda3/bin/python --version
---> Running in ebfecf1ae0b4
Python 3.8.3
Removing intermediate container ebfecf1ae0b4
---> 38905c06c230
Step 4/5 : WORKDIR /home/bizz
---> Running in 4a72d8a73347
Removing intermediate container 4a72d8a73347
---> 7a0ab5136f38
Step 5/5 : RUN ["/bin/bash", "-c", "java -version"]
---> Running in ebf8688d442b
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
Removing intermediate container ebf8688d442b
---> 95b5b0161d7b
Successfully built 95b5b0161d7b
Successfully tagged jcm9812/docker_custom_image:latest
root@bizz:/tmp# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
jcm9812/docker_custom_image latest 95b5b0161d7b 5 seconds ago 737MB
jcm9812/docker_custom_image 0.2 ad641601e269 14 minutes ago 632MB
docker_custom_image 0.2 ad641601e269 14 minutes ago 632MB
jcm9812/docker_custom_image 0.1 61362b1e924a 3 hours ago 524MB
docker_custom_image 0.1 61362b1e924a 3 hours ago 524MB
jcm9812/dockertest2 0.2 be612743ab2c 7 days ago 70MB
dockertest2 0.2 be612743ab2c 7 days ago 70MB
root@bizz:/tmp#
Make Custom Image
• 최종 이미지 확인
root@bizz:/tmp# docker run -d -it jcm9812/docker_custom_image
ef699044e1d1b2d7936994cd6b9c9b5131ee89757a11c436b30ffac5aeddad75
root@bizz:/tmp# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef699044e1d1 jcm9812/docker_custom_image "/bin/bash" 3 seconds ago Up 1 second objective_gagarin
010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" 2 hours ago Up 2 hours great_ramanujan
c9a417d374a2 ubuntu:18.04 "/bin/bash" 3 hours ago Up 3 hours dockertest
root@bizz:/tmp# docker exec -it ef699044e1d1 bash
(base) root@ef699044e1d1:/home/bizz# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
(base) root@ef699044e1d1:/home/bizz# /root/miniconda3/bin/python --version
Python 3.8.3
(base) root@ef699044e1d1:/home/bizz#
감사합니다

More Related Content

PPTX
Docker workshop
PDF
Using Docker in the Real World
PPTX
Real World Experience of Running Docker in Development and Production
PPTX
Running Docker in Development & Production (DevSum 2015)
PDF
A Hands-on Introduction to Docker
PDF
Docker by Example - Basics
PDF
DCSF19 Dockerfile Best Practices
PDF
Docker by Example - Quiz
Docker workshop
Using Docker in the Real World
Real World Experience of Running Docker in Development and Production
Running Docker in Development & Production (DevSum 2015)
A Hands-on Introduction to Docker
Docker by Example - Basics
DCSF19 Dockerfile Best Practices
Docker by Example - Quiz

What's hot (18)

PDF
DCSF19 Tips and Tricks of the Docker Captains
PDF
DCEU 18: Dockerfile Best Practices
PDF
Solving Real World Production Problems with Docker
PDF
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
PPTX
Continuous delivery with docker
PPTX
Deploying Windows Containers on Windows Server 2016
PDF
Vagrant + Docker provider [+Puppet]
PPTX
The How and Why of Windows containers
PDF
Streamline your development environment with docker
PDF
手把手帶你學Docker 03042017
PDF
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
PDF
DockerCon EU 2018 - Dockerfile Best Practices
PDF
DCSF 19 Deploying Rootless buildkit on Kubernetes
PDF
Puppet and Vagrant in development
PDF
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
PDF
Vagrant and docker
PPTX
Real World Lessons on the Pain Points of Node.js Applications
PDF
Check the version with fixes. Link in description
DCSF19 Tips and Tricks of the Docker Captains
DCEU 18: Dockerfile Best Practices
Solving Real World Production Problems with Docker
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
Continuous delivery with docker
Deploying Windows Containers on Windows Server 2016
Vagrant + Docker provider [+Puppet]
The How and Why of Windows containers
Streamline your development environment with docker
手把手帶你學Docker 03042017
Docker summit 2015: 以 Docker Swarm 打造多主機叢集環境
DockerCon EU 2018 - Dockerfile Best Practices
DCSF 19 Deploying Rootless buildkit on Kubernetes
Puppet and Vagrant in development
當專案漸趕,當遷移也不再那麼難 (Ship Your Projects with Docker EcoSystem)
Vagrant and docker
Real World Lessons on the Pain Points of Node.js Applications
Check the version with fixes. Link in description
Ad

Similar to Creating docker custom image (20)

PPTX
Docker orchestration v4
PPTX
Docker orchestration
PDF
Docker in Action
PDF
Introduction to Docker
PPTX
Academy PRO: Docker. Part 2
PDF
Learning Docker with Thomas
PDF
Docker by Example - Basics
PDF
Docker Compose to Production with Docker Swarm
PPTX
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
PDF
Docker use dockerfile
PPTX
Develop with docker 2014 aug
PDF
Drone CI/CD 自動化測試及部署
PPTX
Java microservicesdockerdockerhubusecase2
PDF
Docker & FieldAware
PPTX
Docker introduction for the beginners
PDF
Preparation study of_docker - (MOSG)
PDF
Introducing Docker
PPTX
How to _docker
PDF
PDF
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Docker orchestration v4
Docker orchestration
Docker in Action
Introduction to Docker
Academy PRO: Docker. Part 2
Learning Docker with Thomas
Docker by Example - Basics
Docker Compose to Production with Docker Swarm
SenchaCon 2016: Develop, Test & Deploy with Docker - Jonas Schwabe
Docker use dockerfile
Develop with docker 2014 aug
Drone CI/CD 自動化測試及部署
Java microservicesdockerdockerhubusecase2
Docker & FieldAware
Docker introduction for the beginners
Preparation study of_docker - (MOSG)
Introducing Docker
How to _docker
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Ad

Recently uploaded (20)

PPT
Teaching material agriculture food technology
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Machine learning based COVID-19 study performance prediction
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Big Data Technologies - Introduction.pptx
PDF
KodekX | Application Modernization Development
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
Teaching material agriculture food technology
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Machine learning based COVID-19 study performance prediction
“AI and Expert System Decision Support & Business Intelligence Systems”
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Big Data Technologies - Introduction.pptx
KodekX | Application Modernization Development
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Building Integrated photovoltaic BIPV_UPV.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Review of recent advances in non-invasive hemoglobin estimation

Creating docker custom image

  • 2. 목차 • Docker • VM 과의 차이 • Docker Image • command • Make Custom Image
  • 3. Docker • 컨테이너 기반의 오픈 소스 가상화 플랫폼 • 애플리케이션을 신속하게 구축, 테스트 및 배 포 가능 • 컨테이너에는 라이브러리, 시스템 도구, 코드, 런타임 등 소프트웨어를 실행하는 데 필요한 모든 것이 포함 • 환경에 구애 받지 않고 애플리케이션을 신속 하게 배포 및 확장
  • 4. VM 과의 차이 • OS+APP+LIB 로 구성된 VM 과는 달리 Docker 는 APP+LIB 만 설치 • OS 자원은 Host OS 와 공유 [VM] [Docker] 가상 머신에 비해 경량화가 가능하며 빠른 처리 속도
  • 5. Docker Image [Docker hub] [Docker host] image pull • Docker 컨테이너를 만들기 위한 템플릿 • 이미지는 컨테이너 실행에 필요한 파일 시스템, 라이브러리, 설정 정보등을 포함 • 같은 이미지에서 여러 개의 컨테이너를 실행할 수 있고 컨테이너가 변해도 이미지 고정
  • 6. Command • docker run – docker image 로 컨테이너 생성 docker run -d -it --name <docker image 이름> < docker hub reference image> • docker exec – 로컬에서 docker 컨테이너 안의 명령을 실행 docker exec -it <CONTAINER ID> <shell> • docker tag – docker hub 에 이미지를 업로드 하기 위해서는 tag 설정 docker tag <IMAGE> <저장소>/<image 이름>:<버전> • docker push – docker image 를 docker hub 에 업로드 docker push <저장소>/<image 이름>:<버전> docker push <docker hub 계정>/<image 이름>:<버전> • docker commit – 컨테이너 생성 이후 변경 사항을 docker image 에 업로드 docker commit <CONTAINER ID> <image 이름>:<버전>
  • 7. Command • docker cp – docker 컨테이너와 로컬과의 파일 복사 docker cp <로컬 파일 명> <CONTAINER ID>:<저장 위치> docker cp <CONTAINER ID>:<저장 위치> <로컬 파일 명>
  • 8. Make Custom Image • APP : python 3.8 – Miniconda3 • APP : java8.0 - openjdk • 고객사 APP 실행 시 필요 library 설치 ubuntu 18.04 + miniconda3 + library ubuntu 18.04 + miniconda ubuntu 18.04 + miniconda + library Dockertest:0.1 Dockertest:0.2 Dockertest:0.3 + jdk
  • 9. Make Custom Image • docker hub 를 통해 ubuntu18.04 image 로 docker 컨테이너 생성 docker run -d -it --name dockertest ubuntu:18.04 root@bizz:/home/bizz# docker run -d -it --name dockertest ubuntu:18.04 Unable to find image 'ubuntu:18.04' locally 18.04: Pulling from library/ubuntu f08d8e2a3ba1: Pull complete 3baa9cb2483b: Pull complete 94e5ff4c0b15: Pull complete 1860925334f9: Pull complete Digest: sha256:05a58ded9a2c792598e8f4aa8ffe300318eac6f294bf4f49a7abae7544918592 Status: Downloaded newer image for ubuntu:18.04 c9a417d374a292db4caebe55abd890986e5a6ca8fc4aba301c8ca058cce8e154 root@bizz:/home/bizz# ls miniconda3 miniconda3_edit.tar.gz miniconda3.tar.gz mount snap root@bizz:/home/bizz# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c9a417d374a2 ubuntu:18.04 "/bin/bash" 56 seconds ago Up 52 seconds dockertest
  • 10. Make Custom Image • ubuntu 에 miniconda3 설치 wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh bash Miniconda3-latest-Linux-x86_64.sh root@c9a417d374a2:/# wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh --2020-08-29 07:26:10-- https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8303, ... Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 93052469 (89M) [application/x-sh] Saving to: 'Miniconda3-latest-Linux-x86_64.sh' Miniconda3-latest-Linux-x86_64.sh 100%[=================================================================================================== =====================================>] 88.74M 10.9MB/s in 9.8s 2020-08-29 07:26:19 (9.04 MB/s) - 'Miniconda3-latest-Linux-x86_64.sh' saved [93052469/93052469] root@c9a417d374a2:/# bash Miniconda3-latest-Linux-x86_64.sh <생략> Thank you for installing Miniconda3! root@c9a417d374a2:/# • docker 컨테이너 접속 docker exec –it c9a417d374a2 bash root@bizz:/home/bizz# docker exec -it c9a417d374a2 bash root@c9a417d374a2:/#
  • 11. Make Custom Image • 1차 이미지 배포 docker commit c9a417d374a2 docker_custom_image:0.1 docker tag docker_custom_image:0.1 jcm9812/docker_custom_image:0.1 docker push jcm9812/docker_custom_image:0.1 root@bizz:/home/bizz# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c9a417d374a2 ubuntu:18.04 "/bin/bash" 26 minutes ago Up 26 minutes dockertest root@bizz:/home/bizz# docker commit c9a417d374a2 docker_custom_image:0.1 sha256:61362b1e924abe4b1384503ce503a9956b3a915e06a66a247e79eff11e4cce25 root@bizz:/home/bizz# docker tag docker_custom_image:0.1 jcm9812/docker_custom_image:0.1 root@bizz:/home/bizz# docker push jcm9812/docker_custom_image:0.1 The push refers to repository [docker.io/jcm9812/docker_custom_image] e335ccd7dfd0: Pushed 001e4a80973b: Layer already exists 2ba5b91ca2b0: Layer already exists 2f37d1102187: Layer already exists 79bde4d54386: Layer already exists 0.1: digest: sha256:f90857818af46db53efbb9ea312dbdd169984db7a14432cbeee3082fd942e1a9 size: 1365 root@bizz:/home/bizz#
  • 12. Make Custom Image • 1차 배포 이미지 로 docker 컨테이너 생성 docker run -d -it jcm9812/docker_custom_image:0.1 - local 에 docker image 가 없을 경우 docker run -d -it docker_custom_image:0.1 - local 에 docker image 가 있을 경우 root@bizz:/home/bizz# docker run -d -it jcm9812/docker_custom_image:0.1 010fecc8215a38ce3cedca84388e2ac4948e609777bb6d32d5d1f15ea7cd0105 root@bizz:/home/bizz# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" 4 seconds ago Up 2 seconds great_ramanujan c9a417d374a2 ubuntu:18.04 "/bin/bash" 2 hours ago Up 2 hours dockertest root@bizz:/tmp# docker cp numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl 010fecc8215a:/tmp root@bizz:/tmp# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" 53 minutes ago Up 53 minutes great_ramanujan c9a417d374a2 ubuntu:18.04 "/bin/bash" 2 hours ago Up 2 hours root@bizz:/tmp# docker exec -it 010fecc8215a bash (base) root@010fecc8215a:/# ls /tmp/ numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl (base) root@010fecc8215a:/# • 라이브러리 컨테이너에 복사(ex : numpy-1.19.1 ) docker cp numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl 010fecc8215a:/tmp docker exec –it 010fecc8215a bash
  • 13. Make Custom Image • 필요 라이브 러리 및 패키지 설치 /root/miniconda3/bin/python -m pip install /tmp/ tmp/numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl (base) root@010fecc8215a:/# /root/miniconda3/bin/python -m pip install /tmp/numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl Processing /tmp/numpy-1.19.1-cp38-cp38-manylinux1_x86_64.whl Installing collected packages: numpy Successfully installed numpy-1.19.1 (base) root@010fecc8215a:/#
  • 14. Make Custom Image • 2차 이미지 빌드 docker commit 010fecc8215a docker_custom_image:0.2 docker tag docker_custom_image:0.1 jcm9812/docker_custom_image:0.2 docker push jcm9812/docker_custom_image:0.2 root@bizz:/tmp# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" About an hour ago Up About an hour great_ramanujan c9a417d374a2 ubuntu:18.04 "/bin/bash" 3 hours ago Up 3 hours dockertest root@bizz:/tmp# docker commit 010fecc8215a docker_custom_image:0.2 sha256:ad641601e269ac243db4f634fa7c3327e4c1e4d1377870ec574b7194ec141756 root@bizz:/tmp# docker tag docker_custom_image:0.2 jcm9812/docker_custom_image:0.2 root@bizz:/tmp# docker push jcm9812/docker_custom_image:0.2 The push refers to repository [docker.io/jcm9812/docker_custom_image] 897b94cf4ef6: Pushed e335ccd7dfd0: Layer already exists 001e4a80973b: Layer already exists 2ba5b91ca2b0: Layer already exists 2f37d1102187: Layer already exists 79bde4d54386: Layer already exists 0.2: digest: sha256:f1da086d73933235864ae1134290dcfdac69dd8faa049426251b5ba154f47319 size: 1577
  • 15. Make Custom Image • 최종 이미지 배포(Dockerfile) - Docker image 생성을 위한 스크립트 # docker image load FROM jcm9812/docker_custom_image:0.2 # docker image load COPY --from=openjdk:8-alpine / / # 내부 명령어 실행 RUN /root/miniconda3/bin/python -version # home directory 설정 WORKDIR /home/bizz # 내부 명령어 실행 RUN ["/bin/bash", "-c", "java -version"] Dockerfile ▪ Docker image 생성을 위한 스크립트 파일 ▪ Docker exec / 설치 / commit 의 일괄 작업의 스크립팅 ▪ docker hub 로 부터 1개 이상의 docker image 사용 가능
  • 16. Make Custom Image • 최종 이미지 배포 root@bizz:/tmp# docker build -t jcm9812/docker_custom_image . Sending build context to Docker daemon 13.35MB Step 1/5 : FROM jcm9812/docker_custom_image:0.2 0.2: Pulling from jcm9812/docker_custom_image Digest: sha256:f1da086d73933235864ae1134290dcfdac69dd8faa049426251b5ba154f47319 Status: Downloaded newer image for jcm9812/docker_custom_image:0.2 ---> ad641601e269 Step 2/5 : COPY --from=openjdk:8-alpine / / ---> Using cache ---> daffe858dbdd Step 3/5 : RUN /root/miniconda3/bin/python --version ---> Running in ebfecf1ae0b4 Python 3.8.3 Removing intermediate container ebfecf1ae0b4 ---> 38905c06c230 Step 4/5 : WORKDIR /home/bizz ---> Running in 4a72d8a73347 Removing intermediate container 4a72d8a73347 ---> 7a0ab5136f38 Step 5/5 : RUN ["/bin/bash", "-c", "java -version"] ---> Running in ebf8688d442b openjdk version "1.8.0_212" OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode) Removing intermediate container ebf8688d442b ---> 95b5b0161d7b Successfully built 95b5b0161d7b Successfully tagged jcm9812/docker_custom_image:latest root@bizz:/tmp# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE jcm9812/docker_custom_image latest 95b5b0161d7b 5 seconds ago 737MB jcm9812/docker_custom_image 0.2 ad641601e269 14 minutes ago 632MB docker_custom_image 0.2 ad641601e269 14 minutes ago 632MB jcm9812/docker_custom_image 0.1 61362b1e924a 3 hours ago 524MB docker_custom_image 0.1 61362b1e924a 3 hours ago 524MB jcm9812/dockertest2 0.2 be612743ab2c 7 days ago 70MB dockertest2 0.2 be612743ab2c 7 days ago 70MB root@bizz:/tmp#
  • 17. Make Custom Image • 최종 이미지 확인 root@bizz:/tmp# docker run -d -it jcm9812/docker_custom_image ef699044e1d1b2d7936994cd6b9c9b5131ee89757a11c436b30ffac5aeddad75 root@bizz:/tmp# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ef699044e1d1 jcm9812/docker_custom_image "/bin/bash" 3 seconds ago Up 1 second objective_gagarin 010fecc8215a jcm9812/docker_custom_image:0.1 "/bin/bash" 2 hours ago Up 2 hours great_ramanujan c9a417d374a2 ubuntu:18.04 "/bin/bash" 3 hours ago Up 3 hours dockertest root@bizz:/tmp# docker exec -it ef699044e1d1 bash (base) root@ef699044e1d1:/home/bizz# java -version openjdk version "1.8.0_212" OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode) (base) root@ef699044e1d1:/home/bizz# /root/miniconda3/bin/python --version Python 3.8.3 (base) root@ef699044e1d1:/home/bizz#