Print
카테고리: [ Cloud Computing & MSA ]
조회수: 3434

1. 개요

CentOS에 Docker 설치


2. EPEL 저장소 설정

# yum install docker
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * rpmforge: ftp.neowiz.com
 * updates: mirror.kakao.com
base                                                                                                                                                     | 3.7 kB     00:00
extras                                                                                                                                                   | 3.4 kB     00:00
mariadb                                                                                                                                                  | 2.9 kB     00:00
mariadb/primary_db                                                                                                                                       |  47 kB     00:00
rpmforge                                                                                                                                                 | 1.9 kB     00:00
updates                                                                                                                                                  | 3.4 kB     00:00
No package docker available.
Error: Nothing to do
# yum install http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
epel-release-6-8.noarch.rpm                                                                                                                              |  14 kB     00:00
Examining /var/tmp/yum-root-CCAvuO/epel-release-6-8.noarch.rpm: epel-release-6-8.noarch
Marking /var/tmp/yum-root-CCAvuO/epel-release-6-8.noarch.rpm to be installed
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * extras: mirror.kakao.com
 * rpmforge: ftp.neowiz.com
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:6-8 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================
 Package                                    Arch                                 Version                           Repository                                              Size
================================================================================================================================================================================
Installing:
 epel-release                               noarch                               6-8                               /epel-release-6-8.noarch                                22 k

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

Total size: 22 k
Installed size: 22 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : epel-release-6-8.noarch                                                                                                                                      1/1
  Verifying  : epel-release-6-8.noarch                                                                                                                                      1/1

Installed:
  epel-release.noarch 0:6-8

Complete!

3. Docker 설치

# yum install docker-io
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirrors.aliyun.com
 * extras: mirror.kakao.com
 * rpmforge: ftp.neowiz.com
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package docker-io.x86_64 0:1.7.1-2.el6 will be installed
--> Processing Dependency: lxc for package: docker-io-1.7.1-2.el6.x86_64
--> Processing Dependency: libcgroup for package: docker-io-1.7.1-2.el6.x86_64
--> Running transaction check
---> Package libcgroup.x86_64 0:0.40.rc1-27.el6_10 will be installed
---> Package lxc.x86_64 0:1.0.11-1.el6 will be installed
--> Processing Dependency: lua-lxc(x86-64) = 1.0.11-1.el6 for package: lxc-1.0.11-1.el6.x86_64
--> Processing Dependency: lua-alt-getopt for package: lxc-1.0.11-1.el6.x86_64
--> Processing Dependency: liblxc.so.1()(64bit) for package: lxc-1.0.11-1.el6.x86_64
--> Running transaction check
---> Package lua-alt-getopt.noarch 0:0.7.0-1.el6 will be installed
---> Package lua-lxc.x86_64 0:1.0.11-1.el6 will be installed
--> Processing Dependency: lua-filesystem for package: lua-lxc-1.0.11-1.el6.x86_64
---> Package lxc-libs.x86_64 0:1.0.11-1.el6 will be installed
--> Running transaction check
---> Package lua-filesystem.x86_64 0:1.4.2-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================================================================================
 Package                                             Arch                                        Version                                                    Repository                                    Size
===============================================================================================================================================================================================================
Installing:
 docker-io                                           x86_64                                      1.7.1-2.el6                                                epel                                         4.6 M
Installing for dependencies:
 libcgroup                                           x86_64                                      0.40.rc1-27.el6_10                                         updates                                      131 k
 lua-alt-getopt                                      noarch                                      0.7.0-1.el6                                                epel                                         6.9 k
 lua-filesystem                                      x86_64                                      1.4.2-1.el6                                                epel                                          24 k
 lua-lxc                                             x86_64                                      1.0.11-1.el6                                               epel                                          16 k
 lxc                                                 x86_64                                      1.0.11-1.el6                                               epel                                         124 k
 lxc-libs                                            x86_64                                      1.0.11-1.el6                                               epel                                         257 k

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

Total size: 5.1 M
Installed size: 20 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lxc-libs-1.0.11-1.el6.x86_64                                                                                                                                                                1/7
  Installing : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                                                           2/7
  Installing : lua-lxc-1.0.11-1.el6.x86_64                                                                                                                                                                 3/7
  Installing : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                                                           4/7
  Installing : lxc-1.0.11-1.el6.x86_64                                                                                                                                                                     5/7
  Installing : libcgroup-0.40.rc1-27.el6_10.x86_64                                                                                                                                                         6/7
  Installing : docker-io-1.7.1-2.el6.x86_64                                                                                                                                                                7/7
  Verifying  : lxc-1.0.11-1.el6.x86_64                                                                                                                                                                     1/7
  Verifying  : lua-lxc-1.0.11-1.el6.x86_64                                                                                                                                                                 2/7
  Verifying  : libcgroup-0.40.rc1-27.el6_10.x86_64                                                                                                                                                         3/7
  Verifying  : lxc-libs-1.0.11-1.el6.x86_64                                                                                                                                                                4/7
  Verifying  : docker-io-1.7.1-2.el6.x86_64                                                                                                                                                                5/7
  Verifying  : lua-alt-getopt-0.7.0-1.el6.noarch                                                                                                                                                           6/7
  Verifying  : lua-filesystem-1.4.2-1.el6.x86_64                                                                                                                                                           7/7

Installed:
  docker-io.x86_64 0:1.7.1-2.el6

Dependency Installed:
  libcgroup.x86_64 0:0.40.rc1-27.el6_10  lua-alt-getopt.noarch 0:0.7.0-1.el6  lua-filesystem.x86_64 0:1.4.2-1.el6  lua-lxc.x86_64 0:1.0.11-1.el6  lxc.x86_64 0:1.0.11-1.el6  lxc-libs.x86_64 0:1.0.11-1.el6

Complete!

4. Docker 기동

# service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:                                           [  OK  ]

5. Nginx 설치

Nginx 설치는 https://sarc.io/index.php/cloud/1158-docker-run-ps-rm 문서를 참고하였음.

5-1. 설치 중

# docker run -d -p 80:80 --name nginx nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from nginx
73cbfbe8400f: Extracting [===============================>                   ] 13.99 MB/22.49 MB
eb08637677e4: Download complete
ac6eef915f61: Download complete
febe2c1150da: Download complete
f8fbc5705112: Download complete
a40ea90e0e75: Download complete
6e9099612f51: Download complete
391074e0c4d8: Download complete
f38dde71fabb: Download complete
62d0e0b67f32: Download complete

5-2. 설치 완료

# docker run -d -p 80:80 --name nginx nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from nginx
73cbfbe8400f: Pull complete
eb08637677e4: Pull complete
ac6eef915f61: Pull complete
febe2c1150da: Pull complete
f8fbc5705112: Pull complete
a40ea90e0e75: Pull complete
6e9099612f51: Pull complete
391074e0c4d8: Pull complete
f38dde71fabb: Pull complete
62d0e0b67f32: Pull complete
Digest: sha256:f73de1727b6031a13e00ea697821a496dfedf47af7d41d28c56d9a01389d44bb
Status: Downloaded newer image for nginx:latest
4fc3c04330a97e2ff9323bf7293095fca868e0827c990e4c87e2f5e4f3416219

5-3. docker ps

# docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                NAMES
4fc3c04330a9        nginx               "nginx -g 'daemon of   2 minutes ago       Up 2 minutes        0.0.0.0:80->80/tcp   nginx

5-4. 호출

# curl http://127.0.0.1:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>