Docker/Apache起動イメージ
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
]
開始行:
[[Docker]]
#contents
**Docker Apache 起動イメージ [#nc0c78d0]
Docker を使用し、コンテナを起動したら Apache が自動で起動...
~
Docker のコンテナ起動時には一つのプロセスしか指定できない...
~
1. docker run /usr/sbin/apache2 -DFOREGROUND のように Apa...
2. monit や [[supervisor:https://docs.docker.com/articles...
3. Dockerfile を使ってコンテナイメージを作成し、Dockerfil...
~
といった方法があります。~
1 の場合はログを確認する方法がありません。~
2 の場合は Apache の他に ssh-server をインストールしてお...
~
そこで、3 の Dockerfile を作成し ENTRYPOINT を指定する方...
以下、 Dockerfile を使ってイメージを作成する手順と、その...
~
[[Docker/設定と動作確認]] と同じ環境での作業を想定してい...
~
** Dockerfile [#if523fd6]
まず以下のような Dockerfile を作成します。
FROM centos
MAINTAINER otsuka
RUN yum -y update && yum -y upgrade
RUN yum install -y httpd
RUN yum install -y openssh openssh-server openssh-client...
RUN useradd beat
RUN passwd -f -u beat
RUN mkdir -p /home/beat/.ssh;chown beat /home/beat/.ssh;...
ADD ./authorized_keys /home/beat/.ssh/authorized_keys
RUN chown beat /home/beat/.ssh/authorized_keys;chmod 600...
RUN echo "beat ALL=(ALL) ALL" >> /etc/sudoers.d/beat
#ADD ./sshd_config /etc/ssh/sshd_config
RUN sed -ri "s/^UsePAM yes/#UsePAM yes/" /etc/ssh/sshd_c...
RUN sed -ri "s/^#UsePAM no/UsePAM no/" /etc/ssh/sshd_con...
RUN /etc/init.d/sshd start;/etc/init.d/sshd stop
EXPOSE 80 22
ENTRYPOINT /etc/init.d/httpd start && /etc/init.d/sshd s...
行っているのは以下のような内容です。~
~
CentOS イメージを pull してきてベースにする。~
yum で CentOS を最新の状態に更新する。~
httpd と sshd のパッケージをインストールする。(依存関係...
beat ユーザーを追加し、アカウント使用可能に設定する。~
ssh でのログインは公開鍵認証を使用することにし、先に作成...
beat ユーザーを sudoer に追加する。~
PAM が有効になっているとコンテナにログインできないのでssh...
sshd を一度動作させて host key ファイルを作成させておく。~
port 80 と 22 をフォワードして公開。~
起動時に httpd と sshd をサービスとして起動し bash を起動...
~
このような設定になっているので、~
Dockerfile と同じ場所に authorized_keys を用意し、docker ...
*** authorized_keys [#p6f175c4]
公開鍵 authorized_keys は ssh-keygen で以下のように作成し...
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/beat/.ssh/id_...
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/beat/.ssh/id...
Your public key has been saved in /home/beat/.ssh/id_rsa...
The key fingerprint is:
32:68:59:0f:88:06:ee:c6:f9:5f:44:1e:8e:1b:6d:af beat@doc...
The key's randomart image is:
+--[ RSA 2048]----+
|. |
|.. . . |
| .o . oo |
|o.. +*o. |
| = +oo*S |
|. .. =o. |
| . . . . |
| . . . |
| . E |
+-----------------+
生成された公開鍵 id_rsa.pub を Dockerfile と同じ PATH に ...
$ cp ~/.ssh/id_rsa.pub authorized_keys
**build [#wc013bf5]
用意が出来たらタグを指定して docker build を実行します。
$ sudo docker build -t centos:apache-pm .
Uploading context 4.096 kB
Uploading context
Step 0 : FROM centos
---> 0c752394b855
Step 1 : MAINTAINER otsuka
---> Running in 33c852790c37
---> af203b927e15
Removing intermediate container 33c852790c37
Step 2 : RUN yum -y update && yum -y upgrade
---> Running in 0af65bb828fc
Loaded plugins: fastestmirror
Setting up Update Process
No Packages marked for Update
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
Setting up Upgrade Process
No Packages marked for Update
---> 8b2ddfc67d51
Removing intermediate container 0af65bb828fc
Step 3 : RUN yum install -y httpd
---> Running in d285859a071d
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-30.el6.centos will be...
--> Processing Dependency: httpd-tools = 2.2.15-30.el6.c...
--> Processing Dependency: system-logos >= 7.92.1-1 for ...
--> Processing Dependency: initscripts >= 8.36 for packa...
--> Processing Dependency: apr-util-ldap for package: ht...
--> Processing Dependency: /etc/mime.types for package: ...
--> Processing Dependency: libaprutil-1.so.0()(64bit) fo...
--> Processing Dependency: libapr-1.so.0()(64bit) for pa...
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be i...
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will...
---> Package httpd-tools.x86_64 0:2.2.15-30.el6.centos w...
---> Package initscripts.x86_64 0:9.03.40-2.el6.centos.1...
--> Processing Dependency: upstart >= 0.6.0 for package:...
--> Processing Dependency: ethtool >= 1.8-2 for package:...
--> Processing Dependency: /sbin/ip for package: initscr...
--> Processing Dependency: /sbin/arping for package: ini...
---> Package mailcap.noarch 0:2.1.31-2.el6 will be insta...
---> Package redhat-logos.noarch 0:60.0.14-12.el6.centos...
--> Running transaction check
---> Package ethtool.x86_64 2:3.5-1.4.el6_5 will be inst...
---> Package iproute.x86_64 0:2.6.32-32.el6_5 will be in...
--> Processing Dependency: iptables >= 1.4.5 for package...
--> Processing Dependency: libxtables.so.4()(64bit) for ...
---> Package iputils.x86_64 0:20071127-17.el6_4.2 will b...
---> Package upstart.x86_64 0:0.6.5-13.el6_5.3 will be i...
--> Running transaction check
---> Package iptables.x86_64 0:1.4.7-11.el6 will be inst...
--> Processing Dependency: policycoreutils for package: ...
--> Running transaction check
---> Package policycoreutils.x86_64 0:2.0.83-19.39.el6 w...
--> Finished Dependency Resolution
Dependencies Resolved
========================================================...
Package Arch Version ...
========================================================...
Installing:
httpd x86_64 2.2.15-30.el6.centos ...
Installing for dependencies:
apr x86_64 1.3.9-5.el6_2 ...
apr-util x86_64 1.3.9-3.el6_0.1 ...
apr-util-ldap x86_64 1.3.9-3.el6_0.1 ...
ethtool x86_64 2:3.5-1.4.el6_5 ...
httpd-tools x86_64 2.2.15-30.el6.centos ...
initscripts x86_64 9.03.40-2.el6.centos.1 ...
iproute x86_64 2.6.32-32.el6_5 ...
iptables x86_64 1.4.7-11.el6 ...
iputils x86_64 20071127-17.el6_4.2 ...
mailcap noarch 2.1.31-2.el6 ...
policycoreutils x86_64 2.0.83-19.39.el6 ...
redhat-logos noarch 60.0.14-12.el6.centos ...
upstart x86_64 0.6.5-13.el6_5.3 ...
Transaction Summary
========================================================...
Install 14 Package(s)
Total download size: 18 M
Installed size: 30 M
Downloading Packages:
--------------------------------------------------------...
Total 2.9 MB/s...
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature...
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-...
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <...
Package: centos-release-6-5.el6.centos.11.2.x86_64 (@Up...
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' ou...
udev-147-2.51.el6.x86_64 has missing requires of /sbin/s...
udev-147-2.51.el6.x86_64 has missing requires of MAKEDEV...
Installing : apr-1.3.9-5.el6_2.x86_64 ...
Installing : apr-util-1.3.9-3.el6_0.1.x86_64 ...
Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 ...
Installing : httpd-tools-2.2.15-30.el6.centos.x86_64 ...
Installing : mailcap-2.1.31-2.el6.noarch ...
Installing : upstart-0.6.5-13.el6_5.3.x86_64 ...
Installing : redhat-logos-60.0.14-12.el6.centos.noarch...
Installing : 2:ethtool-3.5-1.4.el6_5.x86_64 ...
Installing : iputils-20071127-17.el6_4.2.x86_64 ...
Installing : iproute-2.6.32-32.el6_5.x86_64 ...
Installing : initscripts-9.03.40-2.el6.centos.1.x86_64...
Installing : policycoreutils-2.0.83-19.39.el6.x86_64 ...
Installing : iptables-1.4.7-11.el6.x86_64 ...
Installing : httpd-2.2.15-30.el6.centos.x86_64 ...
Verifying : httpd-2.2.15-30.el6.centos.x86_64 ...
Verifying : apr-1.3.9-5.el6_2.x86_64 ...
Verifying : 2:ethtool-3.5-1.4.el6_5.x86_64 ...
Verifying : iproute-2.6.32-32.el6_5.x86_64 ...
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 ...
Verifying : initscripts-9.03.40-2.el6.centos.1.x86_64...
Verifying : iputils-20071127-17.el6_4.2.x86_64 ...
Verifying : redhat-logos-60.0.14-12.el6.centos.noarch...
Verifying : iptables-1.4.7-11.el6.x86_64 ...
Verifying : upstart-0.6.5-13.el6_5.3.x86_64 ...
Verifying : mailcap-2.1.31-2.el6.noarch ...
Verifying : httpd-tools-2.2.15-30.el6.centos.x86_64 ...
Verifying : apr-util-1.3.9-3.el6_0.1.x86_64 ...
Verifying : policycoreutils-2.0.83-19.39.el6.x86_64 ...
Installed:
httpd.x86_64 0:2.2.15-30.el6.centos ...
Dependency Installed:
apr.x86_64 0:1.3.9-5.el6_2 ...
apr-util.x86_64 0:1.3.9-3.el6_0.1 ...
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 ...
ethtool.x86_64 2:3.5-1.4.el6_5 ...
httpd-tools.x86_64 0:2.2.15-30.el6.centos ...
initscripts.x86_64 0:9.03.40-2.el6.centos.1 ...
iproute.x86_64 0:2.6.32-32.el6_5 ...
iptables.x86_64 0:1.4.7-11.el6 ...
iputils.x86_64 0:20071127-17.el6_4.2 ...
mailcap.noarch 0:2.1.31-2.el6 ...
policycoreutils.x86_64 0:2.0.83-19.39.el6 ...
redhat-logos.noarch 0:60.0.14-12.el6.centos ...
upstart.x86_64 0:0.6.5-13.el6_5.3 ...
Complete!
---> d55e52846a21
Removing intermediate container d285859a071d
Step 4 : RUN yum install -y openssh openssh-server opens...
---> Running in cc0c2a23a03d
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssh.x86_64 0:5.3p1-94.el6 will be insta...
--> Processing Dependency: libfipscheck.so.1()(64bit) fo...
---> Package openssh-clients.x86_64 0:5.3p1-94.el6 will ...
--> Processing Dependency: libedit.so.0()(64bit) for pac...
---> Package openssh-server.x86_64 0:5.3p1-94.el6 will b...
---> Package sudo.x86_64 0:1.8.6p3-12.el6 will be instal...
--> Processing Dependency: vim-minimal for package: sudo...
--> Running transaction check
---> Package fipscheck-lib.x86_64 0:1.2.0-7.el6 will be ...
--> Processing Dependency: /usr/bin/fipscheck for packag...
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 w...
---> Package vim-minimal.x86_64 2:7.2.411-1.8.el6 will b...
--> Running transaction check
---> Package fipscheck.x86_64 0:1.2.0-7.el6 will be inst...
--> Finished Dependency Resolution
Dependencies Resolved
========================================================...
Package Arch Version ...
...
========================================================...
Installing:
openssh x86_64 5.3p1-94.el6 ...
openssh-clients x86_64 5.3p1-94.el6 ...
openssh-server x86_64 5.3p1-94.el6 ...
sudo x86_64 1.8.6p3-12.el6 ...
Installing for dependencies:
fipscheck x86_64 1.2.0-7.el6 ...
fipscheck-lib x86_64 1.2.0-7.el6 ...
libedit x86_64 2.11-4.20080712cvs.1.e...
vim-minimal x86_64 2:7.2.411-1.8.el6 ...
Transaction Summary
========================================================...
Install 8 Package(s)
Total download size: 2.1 M
Installed size: 5.8 M
Downloading Packages:
--------------------------------------------------------...
Total 2.2 MB/s...
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : fipscheck-lib-1.2.0-7.el6.x86_64 ...
Installing : fipscheck-1.2.0-7.el6.x86_64 ...
Installing : openssh-5.3p1-94.el6.x86_64 ...
Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64 ...
Installing : 2:vim-minimal-7.2.411-1.8.el6.x86_64 ...
Installing : sudo-1.8.6p3-12.el6.x86_64 ...
Installing : openssh-clients-5.3p1-94.el6.x86_64 ...
Installing : openssh-server-5.3p1-94.el6.x86_64 ...
Verifying : 2:vim-minimal-7.2.411-1.8.el6.x86_64 ...
Verifying : libedit-2.11-4.20080712cvs.1.el6.x86_64 ...
Verifying : fipscheck-1.2.0-7.el6.x86_64 ...
Verifying : sudo-1.8.6p3-12.el6.x86_64 ...
Verifying : openssh-5.3p1-94.el6.x86_64 ...
Verifying : openssh-server-5.3p1-94.el6.x86_64 ...
Verifying : openssh-clients-5.3p1-94.el6.x86_64 ...
Verifying : fipscheck-lib-1.2.0-7.el6.x86_64 ...
Installed:
openssh.x86_64 0:5.3p1-94.el6 openssh-clients...
openssh-server.x86_64 0:5.3p1-94.el6 sudo.x86_64 0:1...
Dependency Installed:
fipscheck.x86_64 0:1.2.0-7.el6 ...
fipscheck-lib.x86_64 0:1.2.0-7.el6 ...
libedit.x86_64 0:2.11-4.20080712cvs.1.el6 ...
vim-minimal.x86_64 2:7.2.411-1.8.el6 ...
Complete!
---> 862fb101de8b
Removing intermediate container cc0c2a23a03d
Step 5 : RUN useradd beat
---> Running in 127cf271ea82
---> de6b43bc16a1
Removing intermediate container 127cf271ea82
Step 6 : RUN passwd -f -u beat
---> Running in e38772cc9f23
Unlocking password for user beat.
passwd: Success
---> 553e2712a32d
Removing intermediate container e38772cc9f23
Step 7 : RUN mkdir -p /home/beat/.ssh;chown beat /home/b...
---> Running in a1864a63b96b
---> 3a3e6f141821
Removing intermediate container a1864a63b96b
Step 8 : ADD ./authorized_keys /home/beat/.ssh/authorize...
---> c8613031a181
Removing intermediate container e313d28a4cde
Step 9 : RUN chown beat /home/beat/.ssh/authorized_keys;...
---> Running in 5698592d5f42
---> ca1dd0db4daf
Removing intermediate container 5698592d5f42
Step 10 : RUN echo "beat ALL=(ALL) ALL" >> /etc/sudoers....
---> Running in 004f9a100c56
---> 4f2da3069f62
Removing intermediate container 004f9a100c56
Step 11 : RUN sed -ri "s/^UsePAM yes/#UsePAM yes/" /etc/...
---> Running in 1f25a008e916
---> 3a4f5eab72b4
Removing intermediate container 1f25a008e916
Step 12 : RUN sed -ri "s/^#UsePAM no/UsePAM no/" /etc/ss...
---> Running in b5a823a4dc7b
---> 8cf31df161ad
Removing intermediate container b5a823a4dc7b
Step 13 : RUN /etc/init.d/sshd start;/etc/init.d/sshd stop
---> Running in 6b2d69ec637d
Generating SSH1 RSA host key: [ OK ]
Generating SSH2 RSA host key: [ OK ]
Generating SSH2 DSA host key: [ OK ]
Starting sshd: [ OK ]
Stopping sshd: [ OK ]
---> 43c54ea9b425
Removing intermediate container 6b2d69ec637d
Step 14 : EXPOSE 80 22
---> Running in 18f732a7d365
---> fcc407208a56
Removing intermediate container 18f732a7d365
Step 15 : ENTRYPOINT /etc/init.d/httpd start && /etc/ini...
---> Running in 1b6375ebd85f
---> 8bdcbe80c0b3
Removing intermediate container 1b6375ebd85f
Successfully built 8bdcbe80c0b3
作業単位ごとに commit が行われ、エラーがなければその作業...
作成したイメージが出来ているか確認します。
$ sudo docker images
[sudo] password for beat:
REPOSITORY TAG IMAGE ID ...
centos apache-pm d86505357c6f ...
centos centos6 0c752394b855 ...
centos latest 0c752394b855...
mysite-test latest f7961339d47b ...
django-test latest dea9ca265d14 ...
centos 6.4 539c0211cd76 ...
build 時に指定した centos:apache-pm が出来ています。
** docker run のオプション [#d7b9620a]
Dockerfileで ENTRYPOINT を指定した場合は、コマンド(/bin/...
$ sudo docker run -i -t -p 80:80 -p 22:22 centos:apache-pm
このオプションでイメージを起動すると bash が forground で...
port 80 と 22 をフォワードしているので、ホストOS の IP ア...
このオプションで起動した場合は bash を exit するとイメー...
~
オプション -d を加えると detach 状態の shell なしでコンテ...
$ sudo docker run -i -t -d -p 80:80 -p 22:22 centos:apac...
~
http で見せるコンテンツが修正されるたびに docker build で...
その場合は Dockerfile にコンテンツのイメージ内へのコピー...
コンテンツが git で管理されているのであれば
RUN git clone http://git.someurl
ローカルファイルであれば
ADD /var/www/html/* /var/www/html/
といったコマンドを追加する必要があります。~
~
~
管理の自由度を増すためコンテンツだけはホストOS上に展開し、~
それをコンテナ内の httpd で外部に公開するには、~
以下のようなオプションで docker run を実行しコンテナを起...
$ sudo docker run -i -t -d -v /home/beat/web-contents/:/...
オプション -v ホストOS上のPATH : コンテナ内のPATH~
の指定でホストOS上のディレクトリをコンテナ内にマウントす...
ホストOS上でコンテンツを配置しているディレクトリを、コン...
コンテナ内の httpd で外部へ公開することができます。~
上記のコマンド例では /home/beat/web-contents に置いた公開...
** 更新履歴 [#r6e1fbe1]
2014/06/13 初稿公開 ~
RIGHT:Satoshi OTSUKA
終了行:
[[Docker]]
#contents
**Docker Apache 起動イメージ [#nc0c78d0]
Docker を使用し、コンテナを起動したら Apache が自動で起動...
~
Docker のコンテナ起動時には一つのプロセスしか指定できない...
~
1. docker run /usr/sbin/apache2 -DFOREGROUND のように Apa...
2. monit や [[supervisor:https://docs.docker.com/articles...
3. Dockerfile を使ってコンテナイメージを作成し、Dockerfil...
~
といった方法があります。~
1 の場合はログを確認する方法がありません。~
2 の場合は Apache の他に ssh-server をインストールしてお...
~
そこで、3 の Dockerfile を作成し ENTRYPOINT を指定する方...
以下、 Dockerfile を使ってイメージを作成する手順と、その...
~
[[Docker/設定と動作確認]] と同じ環境での作業を想定してい...
~
** Dockerfile [#if523fd6]
まず以下のような Dockerfile を作成します。
FROM centos
MAINTAINER otsuka
RUN yum -y update && yum -y upgrade
RUN yum install -y httpd
RUN yum install -y openssh openssh-server openssh-client...
RUN useradd beat
RUN passwd -f -u beat
RUN mkdir -p /home/beat/.ssh;chown beat /home/beat/.ssh;...
ADD ./authorized_keys /home/beat/.ssh/authorized_keys
RUN chown beat /home/beat/.ssh/authorized_keys;chmod 600...
RUN echo "beat ALL=(ALL) ALL" >> /etc/sudoers.d/beat
#ADD ./sshd_config /etc/ssh/sshd_config
RUN sed -ri "s/^UsePAM yes/#UsePAM yes/" /etc/ssh/sshd_c...
RUN sed -ri "s/^#UsePAM no/UsePAM no/" /etc/ssh/sshd_con...
RUN /etc/init.d/sshd start;/etc/init.d/sshd stop
EXPOSE 80 22
ENTRYPOINT /etc/init.d/httpd start && /etc/init.d/sshd s...
行っているのは以下のような内容です。~
~
CentOS イメージを pull してきてベースにする。~
yum で CentOS を最新の状態に更新する。~
httpd と sshd のパッケージをインストールする。(依存関係...
beat ユーザーを追加し、アカウント使用可能に設定する。~
ssh でのログインは公開鍵認証を使用することにし、先に作成...
beat ユーザーを sudoer に追加する。~
PAM が有効になっているとコンテナにログインできないのでssh...
sshd を一度動作させて host key ファイルを作成させておく。~
port 80 と 22 をフォワードして公開。~
起動時に httpd と sshd をサービスとして起動し bash を起動...
~
このような設定になっているので、~
Dockerfile と同じ場所に authorized_keys を用意し、docker ...
*** authorized_keys [#p6f175c4]
公開鍵 authorized_keys は ssh-keygen で以下のように作成し...
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/beat/.ssh/id_...
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/beat/.ssh/id...
Your public key has been saved in /home/beat/.ssh/id_rsa...
The key fingerprint is:
32:68:59:0f:88:06:ee:c6:f9:5f:44:1e:8e:1b:6d:af beat@doc...
The key's randomart image is:
+--[ RSA 2048]----+
|. |
|.. . . |
| .o . oo |
|o.. +*o. |
| = +oo*S |
|. .. =o. |
| . . . . |
| . . . |
| . E |
+-----------------+
生成された公開鍵 id_rsa.pub を Dockerfile と同じ PATH に ...
$ cp ~/.ssh/id_rsa.pub authorized_keys
**build [#wc013bf5]
用意が出来たらタグを指定して docker build を実行します。
$ sudo docker build -t centos:apache-pm .
Uploading context 4.096 kB
Uploading context
Step 0 : FROM centos
---> 0c752394b855
Step 1 : MAINTAINER otsuka
---> Running in 33c852790c37
---> af203b927e15
Removing intermediate container 33c852790c37
Step 2 : RUN yum -y update && yum -y upgrade
---> Running in 0af65bb828fc
Loaded plugins: fastestmirror
Setting up Update Process
No Packages marked for Update
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
Setting up Upgrade Process
No Packages marked for Update
---> 8b2ddfc67d51
Removing intermediate container 0af65bb828fc
Step 3 : RUN yum install -y httpd
---> Running in d285859a071d
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-30.el6.centos will be...
--> Processing Dependency: httpd-tools = 2.2.15-30.el6.c...
--> Processing Dependency: system-logos >= 7.92.1-1 for ...
--> Processing Dependency: initscripts >= 8.36 for packa...
--> Processing Dependency: apr-util-ldap for package: ht...
--> Processing Dependency: /etc/mime.types for package: ...
--> Processing Dependency: libaprutil-1.so.0()(64bit) fo...
--> Processing Dependency: libapr-1.so.0()(64bit) for pa...
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be i...
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will...
---> Package httpd-tools.x86_64 0:2.2.15-30.el6.centos w...
---> Package initscripts.x86_64 0:9.03.40-2.el6.centos.1...
--> Processing Dependency: upstart >= 0.6.0 for package:...
--> Processing Dependency: ethtool >= 1.8-2 for package:...
--> Processing Dependency: /sbin/ip for package: initscr...
--> Processing Dependency: /sbin/arping for package: ini...
---> Package mailcap.noarch 0:2.1.31-2.el6 will be insta...
---> Package redhat-logos.noarch 0:60.0.14-12.el6.centos...
--> Running transaction check
---> Package ethtool.x86_64 2:3.5-1.4.el6_5 will be inst...
---> Package iproute.x86_64 0:2.6.32-32.el6_5 will be in...
--> Processing Dependency: iptables >= 1.4.5 for package...
--> Processing Dependency: libxtables.so.4()(64bit) for ...
---> Package iputils.x86_64 0:20071127-17.el6_4.2 will b...
---> Package upstart.x86_64 0:0.6.5-13.el6_5.3 will be i...
--> Running transaction check
---> Package iptables.x86_64 0:1.4.7-11.el6 will be inst...
--> Processing Dependency: policycoreutils for package: ...
--> Running transaction check
---> Package policycoreutils.x86_64 0:2.0.83-19.39.el6 w...
--> Finished Dependency Resolution
Dependencies Resolved
========================================================...
Package Arch Version ...
========================================================...
Installing:
httpd x86_64 2.2.15-30.el6.centos ...
Installing for dependencies:
apr x86_64 1.3.9-5.el6_2 ...
apr-util x86_64 1.3.9-3.el6_0.1 ...
apr-util-ldap x86_64 1.3.9-3.el6_0.1 ...
ethtool x86_64 2:3.5-1.4.el6_5 ...
httpd-tools x86_64 2.2.15-30.el6.centos ...
initscripts x86_64 9.03.40-2.el6.centos.1 ...
iproute x86_64 2.6.32-32.el6_5 ...
iptables x86_64 1.4.7-11.el6 ...
iputils x86_64 20071127-17.el6_4.2 ...
mailcap noarch 2.1.31-2.el6 ...
policycoreutils x86_64 2.0.83-19.39.el6 ...
redhat-logos noarch 60.0.14-12.el6.centos ...
upstart x86_64 0.6.5-13.el6_5.3 ...
Transaction Summary
========================================================...
Install 14 Package(s)
Total download size: 18 M
Installed size: 30 M
Downloading Packages:
--------------------------------------------------------...
Total 2.9 MB/s...
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature...
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-...
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <...
Package: centos-release-6-5.el6.centos.11.2.x86_64 (@Up...
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' ou...
udev-147-2.51.el6.x86_64 has missing requires of /sbin/s...
udev-147-2.51.el6.x86_64 has missing requires of MAKEDEV...
Installing : apr-1.3.9-5.el6_2.x86_64 ...
Installing : apr-util-1.3.9-3.el6_0.1.x86_64 ...
Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 ...
Installing : httpd-tools-2.2.15-30.el6.centos.x86_64 ...
Installing : mailcap-2.1.31-2.el6.noarch ...
Installing : upstart-0.6.5-13.el6_5.3.x86_64 ...
Installing : redhat-logos-60.0.14-12.el6.centos.noarch...
Installing : 2:ethtool-3.5-1.4.el6_5.x86_64 ...
Installing : iputils-20071127-17.el6_4.2.x86_64 ...
Installing : iproute-2.6.32-32.el6_5.x86_64 ...
Installing : initscripts-9.03.40-2.el6.centos.1.x86_64...
Installing : policycoreutils-2.0.83-19.39.el6.x86_64 ...
Installing : iptables-1.4.7-11.el6.x86_64 ...
Installing : httpd-2.2.15-30.el6.centos.x86_64 ...
Verifying : httpd-2.2.15-30.el6.centos.x86_64 ...
Verifying : apr-1.3.9-5.el6_2.x86_64 ...
Verifying : 2:ethtool-3.5-1.4.el6_5.x86_64 ...
Verifying : iproute-2.6.32-32.el6_5.x86_64 ...
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 ...
Verifying : initscripts-9.03.40-2.el6.centos.1.x86_64...
Verifying : iputils-20071127-17.el6_4.2.x86_64 ...
Verifying : redhat-logos-60.0.14-12.el6.centos.noarch...
Verifying : iptables-1.4.7-11.el6.x86_64 ...
Verifying : upstart-0.6.5-13.el6_5.3.x86_64 ...
Verifying : mailcap-2.1.31-2.el6.noarch ...
Verifying : httpd-tools-2.2.15-30.el6.centos.x86_64 ...
Verifying : apr-util-1.3.9-3.el6_0.1.x86_64 ...
Verifying : policycoreutils-2.0.83-19.39.el6.x86_64 ...
Installed:
httpd.x86_64 0:2.2.15-30.el6.centos ...
Dependency Installed:
apr.x86_64 0:1.3.9-5.el6_2 ...
apr-util.x86_64 0:1.3.9-3.el6_0.1 ...
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 ...
ethtool.x86_64 2:3.5-1.4.el6_5 ...
httpd-tools.x86_64 0:2.2.15-30.el6.centos ...
initscripts.x86_64 0:9.03.40-2.el6.centos.1 ...
iproute.x86_64 0:2.6.32-32.el6_5 ...
iptables.x86_64 0:1.4.7-11.el6 ...
iputils.x86_64 0:20071127-17.el6_4.2 ...
mailcap.noarch 0:2.1.31-2.el6 ...
policycoreutils.x86_64 0:2.0.83-19.39.el6 ...
redhat-logos.noarch 0:60.0.14-12.el6.centos ...
upstart.x86_64 0:0.6.5-13.el6_5.3 ...
Complete!
---> d55e52846a21
Removing intermediate container d285859a071d
Step 4 : RUN yum install -y openssh openssh-server opens...
---> Running in cc0c2a23a03d
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.nara.wide.ad.jp
* extras: ftp.nara.wide.ad.jp
* updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssh.x86_64 0:5.3p1-94.el6 will be insta...
--> Processing Dependency: libfipscheck.so.1()(64bit) fo...
---> Package openssh-clients.x86_64 0:5.3p1-94.el6 will ...
--> Processing Dependency: libedit.so.0()(64bit) for pac...
---> Package openssh-server.x86_64 0:5.3p1-94.el6 will b...
---> Package sudo.x86_64 0:1.8.6p3-12.el6 will be instal...
--> Processing Dependency: vim-minimal for package: sudo...
--> Running transaction check
---> Package fipscheck-lib.x86_64 0:1.2.0-7.el6 will be ...
--> Processing Dependency: /usr/bin/fipscheck for packag...
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 w...
---> Package vim-minimal.x86_64 2:7.2.411-1.8.el6 will b...
--> Running transaction check
---> Package fipscheck.x86_64 0:1.2.0-7.el6 will be inst...
--> Finished Dependency Resolution
Dependencies Resolved
========================================================...
Package Arch Version ...
...
========================================================...
Installing:
openssh x86_64 5.3p1-94.el6 ...
openssh-clients x86_64 5.3p1-94.el6 ...
openssh-server x86_64 5.3p1-94.el6 ...
sudo x86_64 1.8.6p3-12.el6 ...
Installing for dependencies:
fipscheck x86_64 1.2.0-7.el6 ...
fipscheck-lib x86_64 1.2.0-7.el6 ...
libedit x86_64 2.11-4.20080712cvs.1.e...
vim-minimal x86_64 2:7.2.411-1.8.el6 ...
Transaction Summary
========================================================...
Install 8 Package(s)
Total download size: 2.1 M
Installed size: 5.8 M
Downloading Packages:
--------------------------------------------------------...
Total 2.2 MB/s...
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : fipscheck-lib-1.2.0-7.el6.x86_64 ...
Installing : fipscheck-1.2.0-7.el6.x86_64 ...
Installing : openssh-5.3p1-94.el6.x86_64 ...
Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64 ...
Installing : 2:vim-minimal-7.2.411-1.8.el6.x86_64 ...
Installing : sudo-1.8.6p3-12.el6.x86_64 ...
Installing : openssh-clients-5.3p1-94.el6.x86_64 ...
Installing : openssh-server-5.3p1-94.el6.x86_64 ...
Verifying : 2:vim-minimal-7.2.411-1.8.el6.x86_64 ...
Verifying : libedit-2.11-4.20080712cvs.1.el6.x86_64 ...
Verifying : fipscheck-1.2.0-7.el6.x86_64 ...
Verifying : sudo-1.8.6p3-12.el6.x86_64 ...
Verifying : openssh-5.3p1-94.el6.x86_64 ...
Verifying : openssh-server-5.3p1-94.el6.x86_64 ...
Verifying : openssh-clients-5.3p1-94.el6.x86_64 ...
Verifying : fipscheck-lib-1.2.0-7.el6.x86_64 ...
Installed:
openssh.x86_64 0:5.3p1-94.el6 openssh-clients...
openssh-server.x86_64 0:5.3p1-94.el6 sudo.x86_64 0:1...
Dependency Installed:
fipscheck.x86_64 0:1.2.0-7.el6 ...
fipscheck-lib.x86_64 0:1.2.0-7.el6 ...
libedit.x86_64 0:2.11-4.20080712cvs.1.el6 ...
vim-minimal.x86_64 2:7.2.411-1.8.el6 ...
Complete!
---> 862fb101de8b
Removing intermediate container cc0c2a23a03d
Step 5 : RUN useradd beat
---> Running in 127cf271ea82
---> de6b43bc16a1
Removing intermediate container 127cf271ea82
Step 6 : RUN passwd -f -u beat
---> Running in e38772cc9f23
Unlocking password for user beat.
passwd: Success
---> 553e2712a32d
Removing intermediate container e38772cc9f23
Step 7 : RUN mkdir -p /home/beat/.ssh;chown beat /home/b...
---> Running in a1864a63b96b
---> 3a3e6f141821
Removing intermediate container a1864a63b96b
Step 8 : ADD ./authorized_keys /home/beat/.ssh/authorize...
---> c8613031a181
Removing intermediate container e313d28a4cde
Step 9 : RUN chown beat /home/beat/.ssh/authorized_keys;...
---> Running in 5698592d5f42
---> ca1dd0db4daf
Removing intermediate container 5698592d5f42
Step 10 : RUN echo "beat ALL=(ALL) ALL" >> /etc/sudoers....
---> Running in 004f9a100c56
---> 4f2da3069f62
Removing intermediate container 004f9a100c56
Step 11 : RUN sed -ri "s/^UsePAM yes/#UsePAM yes/" /etc/...
---> Running in 1f25a008e916
---> 3a4f5eab72b4
Removing intermediate container 1f25a008e916
Step 12 : RUN sed -ri "s/^#UsePAM no/UsePAM no/" /etc/ss...
---> Running in b5a823a4dc7b
---> 8cf31df161ad
Removing intermediate container b5a823a4dc7b
Step 13 : RUN /etc/init.d/sshd start;/etc/init.d/sshd stop
---> Running in 6b2d69ec637d
Generating SSH1 RSA host key: [ OK ]
Generating SSH2 RSA host key: [ OK ]
Generating SSH2 DSA host key: [ OK ]
Starting sshd: [ OK ]
Stopping sshd: [ OK ]
---> 43c54ea9b425
Removing intermediate container 6b2d69ec637d
Step 14 : EXPOSE 80 22
---> Running in 18f732a7d365
---> fcc407208a56
Removing intermediate container 18f732a7d365
Step 15 : ENTRYPOINT /etc/init.d/httpd start && /etc/ini...
---> Running in 1b6375ebd85f
---> 8bdcbe80c0b3
Removing intermediate container 1b6375ebd85f
Successfully built 8bdcbe80c0b3
作業単位ごとに commit が行われ、エラーがなければその作業...
作成したイメージが出来ているか確認します。
$ sudo docker images
[sudo] password for beat:
REPOSITORY TAG IMAGE ID ...
centos apache-pm d86505357c6f ...
centos centos6 0c752394b855 ...
centos latest 0c752394b855...
mysite-test latest f7961339d47b ...
django-test latest dea9ca265d14 ...
centos 6.4 539c0211cd76 ...
build 時に指定した centos:apache-pm が出来ています。
** docker run のオプション [#d7b9620a]
Dockerfileで ENTRYPOINT を指定した場合は、コマンド(/bin/...
$ sudo docker run -i -t -p 80:80 -p 22:22 centos:apache-pm
このオプションでイメージを起動すると bash が forground で...
port 80 と 22 をフォワードしているので、ホストOS の IP ア...
このオプションで起動した場合は bash を exit するとイメー...
~
オプション -d を加えると detach 状態の shell なしでコンテ...
$ sudo docker run -i -t -d -p 80:80 -p 22:22 centos:apac...
~
http で見せるコンテンツが修正されるたびに docker build で...
その場合は Dockerfile にコンテンツのイメージ内へのコピー...
コンテンツが git で管理されているのであれば
RUN git clone http://git.someurl
ローカルファイルであれば
ADD /var/www/html/* /var/www/html/
といったコマンドを追加する必要があります。~
~
~
管理の自由度を増すためコンテンツだけはホストOS上に展開し、~
それをコンテナ内の httpd で外部に公開するには、~
以下のようなオプションで docker run を実行しコンテナを起...
$ sudo docker run -i -t -d -v /home/beat/web-contents/:/...
オプション -v ホストOS上のPATH : コンテナ内のPATH~
の指定でホストOS上のディレクトリをコンテナ内にマウントす...
ホストOS上でコンテンツを配置しているディレクトリを、コン...
コンテナ内の httpd で外部へ公開することができます。~
上記のコマンド例では /home/beat/web-contents に置いた公開...
** 更新履歴 [#r6e1fbe1]
2014/06/13 初稿公開 ~
RIGHT:Satoshi OTSUKA
ページ名:
BC::labsへの質問は、bc9-dev @ googlegroups.com までお願い致します。