IT. POST LIST

POST ALL LABEL

DOCKER 이미지 제작 공방1 - 현재 os 이미지화

By 때찌때찌맴매 - 4월 10, 2018


DOCKER 이미지 제작 공방

* 여러가지의 이미지 제작 방법을 포스팅 합니다. 이미지 제작 후 https://hub.docker.com/ 으로 업로드 방법은 추후에 포스팅 진행합니다.
             http://khmel.org/?p=891


[ docker 베이스 이미지 제작 - 현재 os 이미지화 ]

* 테스트 서버는 docker가 없는 centos6 os 서버 입니다. 

tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/boot --exclude=/usr/lib/firmware --exclude=/usr/lib/modules --exclude=/usr/lib/udev -cvf {os}.tar /

cat {os}.tar | docker import - {os명}


[root@centos6 ]# docker
-bash: docker: command not found
[root@centos6 ]# mkdir /home/docker-base-image
[root@centos6 ]# cd /home/docker-base-image

[root@centos6 ]# tar --numeric-owner --exclude=/proc --exclude=/sys --exclude=/boot --exclude=/usr/lib/firmware --exclude=/usr/lib/modules --exclude=/usr/lib/udev -cvf centos6-base.tar /
tar: Removing leading `/' from member names
/
/dev/
/dev/vcsa6
/dev/vcs6
/dev/vcsa5
/dev/vcs5
.
.
.
.
[root@centos6 ]# ll
합계 2295524
drwxr-xr-x  2 root root       4096 2018-04-10 10:47 .
drwxr-xr-x. 4 root root       4096 2018-04-10 10:46 ..
-rw-r--r--  1 root root 2350602240 2018-04-10 10:49 centos6-base.tar

* hub.docker 를 통해 이미지 업로드후 pull,run 명령어로 다운 및 실행 할 수 있습니다.
  지금은 그냥 scp를 이용해 테스트 합니다.

[root@centos6 ]# scp centos6-base.tar 192.168.229.224:/home/docker-imgaes/centos6
root@192.168.229.224's password: 
centos6-base.tar        100% 2242MB 124.5MB/s   00:18

* docker 서버 os는  centos7 입니다.

[root@docker]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

[root@docker]# pwd
/home/docker-imgaes/centos6

[root@docker]# ll
합계 2295512
drwxr-xr-x 2 root root         30  4월 10 11:00 .
drwxr-xr-x 6 root root         68  4월 10 11:00 ..
-rw-r--r-- 1 root root 2350602240  4월 10 11:00 centos6-base.tar

[root@docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

[root@docker]# time cat centos6-base.tar | docker import - centos6-base
sha256:4257dd712401282041cbc3501e1eb42f66359fc43aa985cdb56534aad3e21fe6

real 0m36.616s
user 0m1.088s
sys 0m7.615s

[root@docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
centos6-base        latest              4257dd712401        About a minute ago   2.3 GB

[root@docker]# docker run -it --name cent6 centos6-base /bin/bash
[root@183dd65101ce /]# cat /etc/redhat-release 
CentOS release 6.9 (Final)

* 정상적으로 이미지 도킹 및 컨테이너 실행이 되었습니다. 해당 방식은 필요 한 패키지등을 모두 설치 후 제작하면 좋을 것 같고, 필요,불필요 디렉토리등은 제작 명령어의 --exclude 옵션을 이용하시면 되겠습니다.

  • Share:

You Might Also Like

0 개의 댓글