1. 먼저 Docker 에 가입을 하자.
ID와 이메일과 패스워드를 입력 후 Sign up을 클릭한다. |
이메일 계정으로 이동 후 Confirm Your Email 을 클릭한다. |
등록한 ID와 패스워드 입력 후 Login 클릭한다. |
계정 생성이 완료 되었다. |
2. Docker for your machine 을 참고하여 CentOS7 에서 yum으로 Docker 설치하기. (실패 상황)
[binrang@binrang ~]$ sudo yum install docker
[sudo] password for binrang:
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
nodesource | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: ftp.daumkakao.com
* extras: ftp.daumkakao.com
* updates: ftp.daumkakao.com
Resolving Dependencies
......
Dependencies Resolved
============================================================================================================================
Package Arch Version Repository Size
============================================================================================================================
Installing:
docker x86_64 1.10.3-46.el7.centos.14 extras 9.5 M
Updating:
dracut x86_64 033-360.el7_2.1 updates 311 k
initscripts x86_64 9.49.30-1.el7_2.3 updates 429 k
......
Transaction Summary
============================================================================================================================
Install 1 Package (+ 4 Dependent packages)
Upgrade 2 Packages (+15 Dependent packages)
Total size: 20 M
Total download size: 11 M
Is this ok [y/d/N]: y
Downloading packages:
(1/5): docker-common-1.10.3-46.el7.centos.14.x86_64.rpm | 61 kB 00:00:00
(2/5): docker-selinux-1.10.3-46.el7.centos.14.x86_64.rpm | 79 kB 00:00:00
......
Dependency Updated:
device-mapper.x86_64 7:1.02.107-5.el7_2.5 device-mapper-event.x86_64 7:1.02.107-5.el7_2.5
device-mapper-event-libs.x86_64 7:1.02.107-5.el7_2.5 device-mapper-libs.x86_64 7:1.02.107-5.el7_2.5
device-mapper-persistent-data.x86_64 0:0.6.2-1.el7_2 dracut-config-rescue.x86_64 0:033-360.el7_2.1
dracut-network.x86_64 0:033-360.el7_2.1 kmod.x86_64 0:20-8.el7_2
libgudev1.x86_64 0:219-19.el7_2.13 lvm2.x86_64 7:2.02.130-5.el7_2.5
lvm2-libs.x86_64 7:2.02.130-5.el7_2.5 systemd.x86_64 0:219-19.el7_2.13
systemd-libs.x86_64 0:219-19.el7_2.13 systemd-python.x86_64 0:219-19.el7_2.13
systemd-sysv.x86_64 0:219-19.el7_2.13
Complete!
[binrang@binrang ~]$
|
docker 서비스 시작
[binrang@binrang ~]$ sudo service docker start
[sudo] password for binrang:
Redirecting to /bin/systemctl start docker.service
[binrang@binrang ~]$
|
부팅시 서비스 등록
[binrang@binrang ~]$ sudo chkconfig docker on
알림: 'systemctl enable docker.service'에 요청을 전송하고 있습니다.
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[binrang@binrang ~]$
|
docker-engine 을 위해 yum 레포지토리를 등록한다. (이제부터 다시...)
[binrang@binrang ~]$ sudo tee /etc/yum.repos.d/docker.repo <<- 'EOF'
> [dockerrepo]
> name=Docker Repository
> baseurl=https://yum.dockerproject.org/repo/main/centos/7/
> enabled=1
> gpgcheck=1
> gpgkey=https://yum.dockerproject.org/gpg
> EOF
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerporject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
[binrang@binrang ~]$
|
그런데 docker-engine 을 설치하면 아래와 같은 에러가 발생한다.
[binrang@binrang ~]$ sudo yum install docker-engine
[sudo] password for binrang:
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00:00
dockerrepo | 2.9 kB 00:00:00
extras | 3.4 kB 00:00:00
nodesource | 2.5 kB 00:00:00
updates | 3.4 kB 00:00:00
......
Error: docker-engine-selinux conflicts with docker-selinux-1.10.3-46.el7.centos.14.x86_64
Error: docker-engine conflicts with docker-1.10.3-46.el7.centos.14.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
[binrang@binrang ~]$
|
해결방안은 아래와 같다. (기본에 yum 을 이용하여 설치하다 보니 발생한 에러다.)
먼저 docker-selinux 가 설치되어 있는지 체크한다.
[binrang@binrang ~]$ yum list installed|grep docker
docker.x86_64 1.10.3-46.el7.centos.14 @extras
docker-common.x86_64 1.10.3-46.el7.centos.14 @extras
docker-selinux.x86_64 1.10.3-46.el7.centos.14 @extras
[binrang@binrang ~]$
|
yum remove를 이용하여 docker 관련 패키지를 제거한다.
[binrang@binrang ~]$ sudo yum remove docker-selinux.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package docker-selinux.x86_64 0:1.10.3-46.el7.centos.14 will be erased
--> Finished Dependency Resolution
.....
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : docker-selinux-1.10.3-46.el7.centos.14.x86_64 1/1
Verifying : docker-selinux-1.10.3-46.el7.centos.14.x86_64 1/1
Removed:
docker-selinux.x86_64 0:1.10.3-46.el7.centos.14
Complete!
[binrang@binrang ~]$
|
[binrang@binrang ~]$ sudo yum remove docker
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
......
Removed:
docker.x86_64 0:1.10.3-46.el7.centos.14
Complete!
[binrang@binrang ~]$ yum list installed|grep docker
docker-common.x86_64 1.10.3-46.el7.centos.14 @extras
[binrang@binrang ~]$ sudo yum remove docker-common.x86_64
Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
.......
Erasing : docker-common-1.10.3-46.el7.centos.14.x86_64 1/1
Verifying : docker-common-1.10.3-46.el7.centos.14.x86_64 1/1
Removed:
docker-common.x86_64 0:1.10.3-46.el7.centos.14
Complete!
[binrang@binrang ~]$
|
이제 설치를 해보자.
[binrang@binrang ~]$ sudo yum install docker-engine
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.daumkakao.com
* extras: ftp.daumkakao.com
* updates: ftp.daumkakao.com
......
Installed:
docker-engine.x86_64 0:1.12.3-1.el7.centos
Dependency Installed:
docker-engine-selinux.noarch 0:1.12.3-1.el7.centos
Complete!
[binrang@binrang ~]$
|
서비스를 활성화한다.
[binrang@binrang ~]$ sudo systemctl enable docker.service
[sudo] password for binrang:
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[binrang@binrang ~]$
|
Docker daemon을 구동한다.
[binrang@binrang ~]$ sudo systemctl start docker
[binrang@binrang ~]$
|
docker는 항상 root 권한으로 실행하여야 한다.
이미지를 검색해보자. (ubuntu 이미지 및 centos 이미지를 검색해보자.)
우분투 이미지 검색
[binrang@binrang ~]$ sudo docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating s... 5048 [OK]
ubuntu-upstart Upstart is an event-based replacement for ... 68 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 49 [OK]
consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC sessi... 29 [OK]
ubuntu-debootstrap debootstrap --variant=minbase --components... 27 [OK]
torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 27 [OK]
ioft/armhf-ubuntu [ABR] Ubuntu Docker images for the ARMv7(a... 19 [OK]
nickistre/ubuntu-lamp LAMP server on Ubuntu 11 [OK]
nuagebec/ubuntu Simple always updated Ubuntu docker images... 10 [OK]
nickistre/ubuntu-lamp-wordpress LAMP on Ubuntu with wp-cli installed 7 [OK]
nimmis/ubuntu This is a docker images different LTS vers... 5 [OK]
maxexcloo/ubuntu Base image built on Ubuntu with init, Supe... 2 [OK]
jordi/ubuntu Ubuntu Base Image 1 [OK]
darksheer/ubuntu Base Ubuntu Image -- Updated hourly 1 [OK]
admiringworm/ubuntu Base ubuntu images based on the official u... 1 [OK]
labengine/ubuntu Images base ubuntu 0 [OK]
lynxtp/ubuntu https://github.com/lynxtp/docker-ubuntu 0 [OK]
teamrock/ubuntu TeamRock's Ubuntu image configured with AW... 0 [OK]
vcatechnology/ubuntu A Ubuntu image that is updated daily 0 [OK]
datenbetrieb/ubuntu custom flavor of the official ubuntu base ... 0 [OK]
esycat/ubuntu Ubuntu LTS 0 [OK]
konstruktoid/ubuntu Ubuntu base image 0 [OK]
widerplan/ubuntu Our basic Ubuntu images. 0 [OK]
ustclug/ubuntu ubuntu image for docker with USTC mirror 0 [OK]
webhippie/ubuntu Docker images for ubuntu 0 [OK]
[binrang@binrang ~]$
|
CentOS 이미지 검색
[binrang@binrang ~]$ sudo docker search centos
[sudo] password for binrang:
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
centos The official build of CentOS. 2824 [OK]
jdeathe/centos-ssh CentOS-6 6.8 x86_64 / CentOS-7 7.2.1511 x8... 47 [OK]
nimmis/java-centos This is docker images of CentOS 7 with dif... 18 [OK]
million12/centos-supervisor Base CentOS-7 with supervisord launcher, h... 12 [OK]
gluster/gluster-centos Official GlusterFS Image [ CentOS-7 + Glu... 12 [OK]
torusware/speedus-centos Always updated official CentOS docker imag... 8 [OK]
nathonfowlie/centos-jre Latest CentOS image with the JRE pre-insta... 5 [OK]
feduxorg/centos-postgresql Centos Image with postgres 3 [OK]
centos/tools Docker image that has systems administrati... 3 [OK]
centos/mariadb55-centos7 3 [OK]
harisekhon/centos-java Java on CentOS (OpenJDK, tags jre/jdk7-8) 2 [OK]
harisekhon/centos-scala Scala + CentOS (OpenJDK tags 2.10-jre7 - 2... 1 [OK]
sgfinans/docker-centos CentOS with a running sshd and Docker 1 [OK]
darksheer/centos Base Centos Image -- Updated hourly 1 [OK]
blacklabelops/centos CentOS Base Image! Built and Updates Daily! 1 [OK]
timhughes/centos Centos with systemd installed and running 1 [OK]
repositoryjp/centos Docker Image for CentOS. 0 [OK]
kz8s/centos Official CentOS plus epel-release 0 [OK]
grayzone/centos auto build for centos. 0 [OK]
vcatechnology/centos A CentOS Image which is updated daily 0 [OK]
grossws/centos CentOS 6 and 7 base images with gosu and l... 0 [OK]
januswel/centos yum update-ed CentOS image 0 [OK]
ustclug/centos USTC centos 0 [OK]
dmglab/centos CentOS with some extras - This is for the ... 0 [OK]
aguamala/centos CentOS base image 0 [OK]
[binrang@binrang ~]$
|
3. 이제 docker-compose 와 docker-machine 등을 설치하고 버전을 체크해보자.
[binrang@binrang ~]$ docker --version
Docker version 1.12.3, build 6b644ec
[binrang@binrang ~]$
[binrang@binrang ~]$ docker-compose --version
bash: docker-compose: 명령을 찾을 수 없습니다...
[binrang@binrang ~]$
[binrang@binrang ~]$ su -
암호:
마지막 로그인: 월 11월 14 16:14:14 KST 2016 일시 pts/2
[root@binrang ~]#
[root@binrang ~]# curl -L "https://github.com/docker/compose/releases/download/1.8.1/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600 0 600 0 0 654 0 --:--:-- --:--:-- --:--:-- 654
100 7798k 100 7798k 0 0 56176 0 0:02:22 0:02:22 --:--:-- 65338
[root@binrang ~]#
[root@binrang ~]# docker-compose --version
-bash: /usr/local/bin/docker-compose: 허가 거부
[root@binrang ~]#
[root@binrang ~]# chmod +x /usr/local/bin/docker-compose
[root@binrang ~]#
[root@binrang ~]# docker-compose --version
docker-compose version 1.8.1, build 878cff1
[root@binrang ~]#
[root@binrang ~]# docker-machine --version
bash: docker-machine: 명령을 찾을 수 없습니다...
[root@binrang ~]#
[root@binrang ~]# curl -L https://github.com/docker/machine/releases/download/v0.8.2/docker-machine-`uname -s`-`uname -m` >/usr/local/bin/docker-machine && \
> chmod +x /usr/local/bin/docker-machine
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600 0 600 0 0 675 0 --:--:-- --:--:-- --:--:-- 675
100 23.4M 100 23.4M 0 0 66657 0 0:06:08 0:06:08 --:--:-- 85515
[root@binrang ~]# docker-machine --version
docker-machine version 0.8.2, build e18a919
[root@binrang ~]#
|
4. Docker 버전의 'Hello World'를 구동하여 설치를 확인해 본다.
[root@binrang ~]# docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account:
https://hub.docker.com
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
[root@binrang ~]#
|
5. 시스템의 모든 컨테이너를 표시할려면 아래와 같이 명령을 실행한다.
[root@binrang ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c57944bd52a0 hello-world "/hello" 33 seconds ago Exited (0) 33 seconds ago serene_engelbart
[root@binrang ~]#
|
6. 일렉트로이드는 Docker 파일과 Docker 이미지를 가지고 있다. 간단하게 아래 명령어로 가져와보자.
[root@binrang ~]# docker pull electrode/electrode-io
Using default tag: latest
latest: Pulling from electrode/electrode-io
8ad8b3f87b37: Pull complete
751fe39c4d34: Pull complete
ae3b77eefc06: Pull complete
7783aac582ec: Pull complete
393ad8a32e58: Pull complete
dbe45f91a065: Pull complete
a298bba8c573: Pull complete
b0e7c07cc504: Pull complete
9b5162c457bd: Pull complete
405044fb4a85: Pull complete
51a668b04dac: Pull complete
Digest: sha256:11f282f8abad2bb7a880c8278cde4c12aefd13f31f270fdefabe77636d847cd9
Status: Downloaded newer image for electrode/electrode-io:latest
[root@binrang ~]#
|
7. 이제 실행을 해 보자.
[root@binrang ~]# docker run -d -p 3000:3000 electrode/electrode-io
3481b78dc5851357329a6a9871b3c66c2aeff5a2bc8c211d48928255f5dd1e51
[root@binrang ~]#
|
8. 이제 브라우저에서 확인해보자.
Hello Electrode 화면을 볼 수 있다. |
9. 개발을 위해 컨테이너에서 로컬 컴퓨터로 코드를 복사한다.
[root@binrang ~]# docker cp 3481b78dc5851357329a6a9871b3c66c2aeff5a2bc8c211d48928255f5dd1e51:/usr/src/app .
[root@binrang ~]#
|
10. 컨테이너를 중지한다.
[root@binrang ~]# docker stop 3481b78dc5851357329a6a9871b3c66c2aeff5a2bc8c211d48928255f5dd1e51
3481b78dc5851357329a6a9871b3c66c2aeff5a2bc8c211d48928255f5dd1e51
[root@binrang ~]#
|
11. app 디렉토리로 이동 한 후 빌드 명령을 통하여 이미지를 생성해 보자.
[root@binrang ~]# cd app
[root@binrang app]#
[root@binrang app]# docker build -t docker-awesome-container .
Sending build context to Docker daemon 78.85 kB
Step 1 : FROM node:4.5
4.5: Pulling from library/node
6a5a5368e0c2: Pull complete
7b9457ec39de: Pull complete
ff18e19c2db4: Pull complete
6a3d69edbe90: Pull complete
0ce4b037e17f: Pull complete
da5ea9063409: Pull complete
Digest: sha256:73fc0eeef0b0ed8ac38c2b8c861b24f85798f2d7b1e883d19b3a818bc8ad9e25
Status: Downloaded newer image for node:4.5
---> 10a26800d95a
Step 2 : RUN npm i -g npm@3
---> Running in 54011df8044e
npm info it worked if it ends with ok
......
npm http 200 https://registry.npmjs.org/acorn
npm info retry fetch attempt 1 at 8:10:58 AM
npm info attempt registry request try #1 at 8:10:58 AM
npm http fetch GET https://registry.npmjs.org/acorn/-/acorn-4.0.3.tgz
npm http 200 https://registry.npmjs.org/yargs
......
npm info lifecycle braces@0.1.5~preinstall: braces@0.1.5
npm info lifecycle expand-braces@0.1.2~preinstall: expand-braces@0.1.2
npm info lifecycle ms@0.7.1~preinstall: ms@0.7.1
npm info lifecycle debug@2.2.0~preinstall: debug@2.2.0
.......
npm info linkStuff es6-template-strings@2.0.1
npm info linkStuff esprima@2.7.3
npm info linkStuff estraverse@4.1.1
......
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@4.5.0 | linux | x64
gyp http GET https://nodejs.org/download/release/v4.5.0/node-v4.5.0-headers.tar.gz
gyp http 200 https://nodejs.org/download/release/v4.5.0/node-v4.5.0-headers.tar.gz
......
electrode-app-with-electrode-modules@0.0.0 /usr/src/app
+-- above-the-fold-only-server-render@1.0.3
+-- bluebird@3.4.6
+-- electrode-archetype-react-app@1.3.3
+-- babel-core@6.18.2
.......
Time: 10505ms
Asset Size Chunks Chunk Names
bundle.cb48d27b92c98eff729c.js 278 kB 0 [emitted] main
style.cb48d27b92c98eff729c.css 256 bytes 0 [emitted] main
../map/bundle.cb48d27b92c98eff729c.js.map 2.69 MB 0 [emitted] main
../map/style.cb48d27b92c98eff729c.css.map 107 bytes 0 [emitted] main
../server/stats.json 233 bytes [emitted]
../isomorphic-assets.json 239 bytes [emitted]
+ 414 hidden modules
Child extract-text-webpack-plugin:
+ 2 hidden modules
[08:14:13] Finished 'build-dist-min' after 12 s
......
---> 2f232a744240
Removing intermediate container b452e6d4431e
Successfully built 2f232a744240
[root@binrang app]#
|
12. 아래 명령으로 빌드한 이미지를 확인해보자.
[root@binrang app]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-awesome-container latest 2f232a744240 8 minutes ago 1.012 GB
electrode/electrode-io latest dfa4ede1ecab 7 weeks ago 967.4 MB
node 4.5 10a26800d95a 7 weeks ago 648.5 MB
hello-world latest c54a2cc56cbb 4 months ago 1.848 kB
[root@binrang app]#
|
13. 이미지 리스트에서 IMAGE ID 를 확인 후 태그를 부여하여 보자
[root@binrang app]# docker tag 2f232a744240 binrang/docker-awesome-container:latest
[root@binrang app]#
|
14. docker 이미지를 확인해 보면 추가 되어 있는 것을 확인할 수 있다.
[root@binrang app]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
binrang/docker-awesome-container latest 2f232a744240 35 minutes ago 1.012 GB
docker-awesome-container latest 2f232a744240 35 minutes ago 1.012 GB
electrode/electrode-io latest dfa4ede1ecab 7 weeks ago 967.4 MB
node 4.5 10a26800d95a 7 weeks ago 648.5 MB
hello-world latest c54a2cc56cbb 4 months ago 1.848 kB
[root@binrang app]#
|
15. 로컬 컨테이너에서 이미지를 실행하여 보자.
[root@binrang app]# docker run -d -p 3000:3000 docker-awesome-container
861100f9612b6d60cb3dd0ec018405419c7a6a142ce30b43e5b320f3ef3f4a32
[root@binrang app]#
|
16. 브라우저로 확인해보면 Hello Electrode 화면을 볼수 있다.
17. PS를 확인하고 컨테이너를 중지하자.
[root@binrang app]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
861100f9612b docker-awesome-container "/bin/sh -c 'node ser" 8 seconds ago Up 7 seconds 0.0.0.0:3000->3000/tcp drunk_wescoff
[root@binrang app]#
[root@binrang app]# docker stop 861100f9612b6d60cb3dd0ec018405419c7a6a142ce30b43e5b320f3ef3f4a32
861100f9612b6d60cb3dd0ec018405419c7a6a142ce30b43e5b320f3ef3f4a32
[root@binrang app]#
|
18. Docker Hub에 접속을 하자.
[root@binrang app]# docker login --username=binrang --email=binrang44@gmail.com
Flag --email has been deprecated, will be removed in 1.13.
Password:
Login Succeeded
[root@binrang app]#
|
19. Docker Hub에 밀어 넣어보자.
[root@binrang app]# docker push binrang/docker-awesome-container
The push refers to a repository [docker.io/binrang/docker-awesome-container]
06ce445caa0f: Pushed
31043dafd90d: Pushed
ee8a40045164: Pushed
31ce504999c9: Pushed
c17f34daa524: Pushed
ead6e97a5920: Mounted from library/node
decf47a6ae24: Mounted from library/node
d9a069c1d0fc: Mounted from library/node
a5eb0fc1decb: Mounted from library/node
b2ac5371e0f2: Mounted from library/node
142a601d9793: Mounted from library/node
latest: digest: sha256:de183593493d2a300411fa15576cc2813caf1e695c17b8df93fc9116574fcc2b size: 2637
[root@binrang app]#
|
이제 Docker Cloud 레포지토리에 새로운 이미지를 내 계정으로 올려 놓았다. 여기서 이제 배포가 가능하게 된 것이다.
20. docker hub의 대시보드를 체크해보자.
배포가 된 컨테이너를 확인할 수 있다. |
그 외는 Docker의 User Guide 를 참조하자.
참조 URL : Deploy with Docker
댓글 없음:
댓글 쓰기