견적 및 제품문의 : sales@opennaru.com
02-469-5426
분류 전체보기 (127)
오픈나루 소식 (1)
Techie Talk (5)
오픈소스 뉴스 (15)
JBoss EAP (39)
클라우드 (3)
No SQL (12)
UI (1)
Azul Zing (5)
KHAN (25)
BRMS (2)
EAI (2)
Load Test (1)
Java Troubleshooting (3)
Security (1)
Database (1)
docker (10)
memory
memory
href="http://eliteanus.ru/stra..
오픈나루 - Cen..
318,415 Visitors up to today!
Today 245 hit, Yesterday 281 hit
daisy rss
tistory 티스토리 가입하기!
2014.06.24 10:00
CentOS에서 손쉽게 Docker 를 설치하는 방법을 정리하였습니다. Naresh 블로그의 "Installing docker 0.8 version on Centos 6.5( http://nareshv.blogspot.kr/2014/02/installing-docker-08-version-on-centos.html )" 포스트를 번역하고 몇 가지 내용을 추가한 것입니다. CentOS 6.5 와 Docker 1.0.0을 설치하고 dockerhub 으로 부터 Fedora 이미지를 받아서 실행하는 예제입니다.
상세 버전들은 다음과 같습니다.
[admin@localhost /]$ cat /etc/redhat-release CentOS release 6.5 (Final)
[admin@localhost /]$ uname -a
Linux localhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[admin@localhost /]$ sudo docker version
[sudo] password for admin: 
Client version: 1.0.0
Client API version: 1.12
Go version (client): go1.2.2
Git commit (client): 63fe64c/1.0.0
Server version: 1.0.0
Server API version: 1.12
Go version (server): go1.2.2
Git commit (server): 63fe64c/1.0.0
아직 Docker 가 설치되어 있지 않기 때문에  "docker version" 커맨드는 오류가 날것입니다. 

docker를 설치하고 fedora 이미지를 다운로드 받고, docker 컨테이너에서 fedora 를 실행하는 절차는 아래의 내용과 같습니다.

1. EPEL 레파지토리 구성 
[admin@localhost /]$sudo yum install http://ftp.riken.jp/Linux/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
2. EPEL 레파지토리로 부터 docker-io 패키지 설치
[admin@localhost /]$ sudo yum install docker-io
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: centos.tt.co.kr
* epel: mirror.premi.st
* extras: centos.tt.co.kr
* updates: centos.tt.co.kr
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.0.0-3.el6 will be installed
--> Processing Dependency: lxc for package: docker-io-1.0.0-3.el6.x86_64
--> Processing Dependency: libcgroup for package: docker-io-1.0.0-3.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-5.el6_5.1 will be installed
---> Package lxc.x86_64 0:0.9.0-2.el6 will be installed
--> Processing Dependency: liblxc.so.0()(64bit) for package: lxc-0.9.0-2.el6.x86_64
--> Running transaction check
---> Package lxc-libs.x86_64 0:0.9.0-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package          Arch          Version                    Repository      Size
================================================================================
Installing:
docker-io        x86_64        1.0.0-3.el6                epel           4.5 M
Installing for dependencies:
libcgroup        x86_64        0.40.rc1-5.el6_5.1         updates        125 k
lxc              x86_64        0.9.0-2.el6                epel            78 k
lxc-libs         x86_64        0.9.0-2.el6                epel           116 k

Transaction Summary
================================================================================
Install       4 Package(s)

Total download size: 4.8 M
Installed size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): docker-io-1.0.0-3.el6.x86_64.rpm                  | 4.5 MB     00:00     
(2/4): libcgroup-0.40.rc1-5.el6_5.1.x86_64.rpm           | 125 kB     00:00     
(3/4): lxc-0.9.0-2.el6.x86_64.rpm                        |  78 kB     00:00     
(4/4): lxc-libs-0.9.0-2.el6.x86_64.rpm                   | 116 kB     00:00     
--------------------------------------------------------------------------------
Total                                           4.6 MB/s | 4.8 MB     00:01     
경고: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
Userid : EPEL (6) <epel@fedoraproject.org>
Package: epel-release-6-8.noarch (@/epel-release-6-8.noarch)
From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libcgroup-0.40.rc1-5.el6_5.1.x86_64                          1/4 
  Installing : lxc-libs-0.9.0-2.el6.x86_64                                  2/4 
  Installing : lxc-0.9.0-2.el6.x86_64                                       3/4 
  Installing : docker-io-1.0.0-3.el6.x86_64                                 4/4 
  Verifying  : docker-io-1.0.0-3.el6.x86_64                                 1/4 
  Verifying  : lxc-libs-0.9.0-2.el6.x86_64                                  2/4 
  Verifying  : libcgroup-0.40.rc1-5.el6_5.1.x86_64                          3/4 
  Verifying  : lxc-0.9.0-2.el6.x86_64                                       4/4 

Installed:
  docker-io.x86_64 0:1.0.0-3.el6                                                

Dependency Installed:
  libcgroup.x86_64 0:0.40.rc1-5.el6_5.1         lxc.x86_64 0:0.9.0-2.el6        
  lxc-libs.x86_64 0:0.9.0-2.el6                

Complete!

3. docker 실행하기 
[admin@localhost /]$ sudo docker -d &
docker 는 실행되겠지만 kernel 3.8 또는 그 이상으로 업그레이드하라는 경고 메세지가 출력될 것입니다. 

4. elrepo 레포지토리를 구성하여 Kernel 을 3.8 또는 그 이상으로 업그레이드하기
[admin@localhost /]$ sudo  yum install http://www.elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm

5. elrepo 로 부터 kernel-ml 설치하기
[admin@localhost /]$ sudo  yum --enablerepo=elrepo-kernel install kernel-ml

6. 3.15 Kernel 로 변경하기 위해 reboot 하기 ( GRUB 메뉴에서 Kernel 을 선택하는 것을 확인해야함.)
[admin@localhost /]$ sudo reboot

7. 로그인 후에 서버 kernel 버전을 확인 하기
[admin@localhost ~]$ sudo uname -r
[sudo] password for admin: 
3.15.1-1.el6.elrepo.x86_64

8. docker0 인터페이스가 추가되었는지 확인
[admin@localhost ~]$ ifconfig
docker0   Link encap:Ethernet  HWaddr 56:84:7A:FE:97:99  
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

eth1      Link encap:Ethernet  HWaddr 08:00:27:9D:F1:DD  
          inet addr:192.168.0.52  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe9d:f1dd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:461 errors:0 dropped:0 overruns:0 frame:0
          TX packets:219 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:51183 (49.9 KiB)  TX bytes:22032 (21.5 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

9. 데몬으로 docker 실행하기 

[admin@localhost ~]$ sudo docker -d
2014/06/24 09:05:49 docker daemon: 1.0.0 63fe64c/1.0.0; execdriver: native; graphdriver: 
[40a1a09c] +job serveapi(unix:///var/run/docker.sock)
[40a1a09c] +job initserver()
[40a1a09c.initserver()] Creating server
2014/06/24 09:05:49 Listening for HTTP on unix (/var/run/docker.sock)
[40a1a09c] +job init_networkdriver()
[40a1a09c] -job init_networkdriver() = OK (0)
2014/06/24 09:05:49 WARNING: Your kernel does not support cgroup swap limit.
Loading containers: ..........: done.
[40a1a09c.initserver()] Creating pidfile
[40a1a09c.initserver()] Setting up signal traps
[40a1a09c] -job initserver() = OK (0)
[40a1a09c] +job acceptconnections()
[40a1a09c] -job acceptconnections() = OK (0)

10. docker 버전 확인하기 
[admin@localhost ~]$ sudo docker version
[sudo] password for admin: 
Client version: 1.0.0
Client API version: 1.12
Go version (client): go1.2.2
Git commit (client): 63fe64c/1.0.0
Server version: 1.0.0
Server API version: 1.12
Go version (server): go1.2.2
Git commit (server): 63fe64c/1.0.0
docker info 확인하기 
[admin@localhost ~]$ sudo docker info
Containers: 0
Images: 0
Storage Driver: devicemapper
 Pool Name: docker-253:0-149253-pool
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 291.5 Mb
 Data Space Total: 102400.0 Mb
 Metadata Space Used: 0.7 Mb
 Metadata Space Total: 2048.0 Mb
Execution Driver: native-0.2
Kernel Version: 2.6.32-431.el6.x86_64

11. 서비스로 docker 실행하기 
[admin@localhost ~]$ sudo service docker start
Starting docker:                                           [  OK  ]
Restart 시에 자동 실행할 수 있도록 설정합니다.
[admin@localhost ~]$ sudo chkconfig docker on

12.  "unable to remount sys readonly:" 에러 시 다음과 같이 수정

docker 이미지 실행 시에 다음과 같은 에러가 발생할 수 있습니다.
"unable to remount sys readonly: unable to mount sys as readonly max retries reached" 
이럴 경우 당황하시지 말고,  "/etc/sysconfig/docker" 파일의 내용을 다음과 같이 수정합니다.
[admin@localhost ~]$ sudo vi /etc/sysconfig/docker
다음과 같이 수정 하기
--exec-driver=lxc --selinux-enabled

13. Docker 를 이용하여 Fedora 실행해 보기

docker 상태를 아래와 같이 확인합니다.
[admin@localhost ~]$sudo service docker status
docker (pid  1772)를 실행하고 있습니다..
dockerhub 으로 부터 fedora 이미지를 다운로드 받습니다.
[admin@localhost ~]$ sudo docker pull fedora
Pulling repository fedora
64fd7993bcaf: Download complete 
3f2fed40e4b0: Download complete 
511136ea3c5a: Download complete 
fd241224e9cf: Download complete 
다운로드 받은 fedoar 이미지 실행하기
[admin@localhost ~]$  sudo docker run -i -t fedora /bin/bash
bash-4.2# uname -r
3.15.1-1.el6.elrepo.x86_64
bash-4.2# cat /etc/redhat-release 
Fedora release 20 (Heisenbug)
bash-4.2# 

References


저작자 표시
신고
크리에이티브 커먼즈 라이선스
Creative Commons License
Name
Password
Homepage
Secret

티스토리 툴바