body閉じタグの直前にscriptタグを挿入した話(スクレイピング 環境構築に派生した話)

まえがき

スクレイピングなんだろって気になった。ググって、調べていたら、おもしろそうとおもってスクレイピングするローカルホスト環境を構築したいなと思いました。

参考文献

記号を言葉で表現できなかったから調べた。

キーボード特殊記号の読み方  

関数定義と関数呼出の方法知っておけばいいとおもう。

関数の定義と呼び出し  

フォルダ構成

__htmlに対してsedかます

コード表示

[oracle@centos weban]$ ll
合計 192
-rw-r--r--. 1 oracle docker    246  5月 25 08:44 Dockerfile
-rw-r--r--. 1 oracle docker 176088  5月 25 09:57 __.html
-rwxr-xr-x. 1 oracle docker    807  5月 17 16:46 kick.sh
-rw-r--r--. 1 root   root       96  5月 25 09:53 screep.js
drwxr-xr-x. 6 oracle docker   4096  5月 20 20:10 src
drwxr-xr-x. 2 oracle docker   4096  5月 19 22:31 tmp
[oracle@centos weban]$ docker exec -it httpd /bin/bash
[root@6d1f534a84b7 /]# cd /var/www/html
[root@6d1f534a84b7 html]# ll
total 192
-rw-r--r--. 1 1000 1001    246 May 24 23:44 Dockerfile
-rw-r--r--. 1 1000 1001 176088 May 25 00:57 __.html
-rwxr-xr-x. 1 1000 1001    807 May 17 07:46 kick.sh
-rw-r--r--. 1 root root     96 May 25 00:53 screep.js
drwxr-xr-x. 6 1000 1001   4096 May 20 11:10 src
drwxr-xr-x. 2 1000 1001   4096 May 19 13:31 tmp

Dockerfile

コード表示

[oracle@centos weban]$ cat D*
FROM centos:latest

RUN yum install -y httpd \ 
yum install -y iputils \
yum install -y net-tools \
yum install -y iproute \
yum install -y vim \
yum install -y tree \
yum install -y lsof \
yum install -y traceroute

EXPOSE 80
CMD ["/sbin/init"]

コンテナ作成

コード表示

[oracle@centos weban]$ docker build -t centos_httpd .
[oracle@centos weban]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos_httpd        latest              1eeca6ecbb88        2 hours ago         389MB
centos_php          latest              8d9f2dcb8da1        3 days ago          499MB
centos              latest              9f38484d220f        2 months ago        202MB

コンテナ起動

コード表示

[oracle@centos weban]$ docker run --privileged -v $(pwd):/var/www/html -p 8080:80 --name httpd -itd centos_httpd /sbin/init
[oracle@centos weban]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
6d1f534a84b7        centos_httpd        "/sbin/init"        2 hours ago         Up 2 hours          0.0.0.0:8080->80/tcp   httpd

httpdサービス起動

コード表示

[oracle@centos weban]$ docker exec -it httpd systemctl start httpd
[oracle@centos weban]$ docker exec -it httpd systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-05-24 23:58:50 UTC; 1h 36min ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 2663 (httpd)
   Status: "Total requests: 38; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /docker/6d1f534a84b7d7b77dd82169582df46058867c0f159d829c9ff92735d3e28a62/system.slice/httpd.service
           ├─2663 /usr/sbin/httpd -DFOREGROUND
           ├─2664 /usr/sbin/httpd -DFOREGROUND
           ├─2665 /usr/sbin/httpd -DFOREGROUND
           ├─2666 /usr/sbin/httpd -DFOREGROUND
           ├─2667 /usr/sbin/httpd -DFOREGROUND
           ├─2668 /usr/sbin/httpd -DFOREGROUND
           └─2682 /usr/sbin/httpd -DFOREGROUND
           ‣ 2663 /usr/sbin/httpd -DFOREGROUND

May 24 23:58:50 6d1f534a84b7 systemd[1]: Starting The Apache HTTP Server...
May 24 23:58:50 6d1f534a84b7 httpd[2663]: AH00558: httpd: Could not reliably...e
May 24 23:58:50 6d1f534a84b7 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

【OK】埋め込む用のsed

レフト・アングル、ライト・アングルはエスケープしなくてOKだったことに気付いた。

コード表示

sed -e 's/<\/body>/\<script type=\"text\/javascript\" src=\"screep.js\"\>\<\/script\><\/body>/' __.html | grep \</body\>

【NG】埋め込む用のsed

レフト・アングル、ライト・アングルはエスケープしなくてOKだったことに気付いた。

コード表示

sed -e 's/\<\/body\>/\<script type=\"text\/javascript\" src=\"screep.js\"\>\<\/script\><\/body>/' __.html | grep \</body\>

【OK】埋め込む用のsed上書き指定

-i指定

コード表示

sed -i -e 's/<\/body>/\<script type=\"text\/javascript\" src=\"screep.js\"\>\<\/script\><\/body>/' __.html | grep \</body\>

確認

NGパターンで置換していない状態を確認し、OKパターンで置換されたことを確認する。

コード表示

[root@6d1f534a84b7 html]# sed -e 's/\<\/body\>/\<script type=\"text\/javascript\" src=\"screep.js\"\>\<\/script\><\/body>/' __.html | grep \</body\>
<div id="fancybox-tmp"></div><div id="fancybox-loading"><div></div></div><div id="fancybox-overlay"></div><div id="fancybox-wrap"><div id="fancybox-outer"><div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div><div id="fancybox-content"></div><a id="fancybox-close"></a><div id="fancybox-title"></div><a id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a><a id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a></div></div></body>
[root@6d1f534a84b7 html]# sed -e 's/<\/body>/\<script type=\"text\/javascript\" src=\"screep.js\"\>\<\/script\><\/body>/' __.html | grep \</body\>
<div id="fancybox-tmp"></div><div id="fancybox-loading"><div></div></div><div id="fancybox-overlay"></div><div id="fancybox-wrap"><div id="fancybox-outer"><div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div><div id="fancybox-content"></div><a id="fancybox-close"></a><div id="fancybox-title"></div><a id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a><a id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a></div></div><script type="text/javascript" src="screep.js"></script></body>

スクレイピングの練習環境をミニマムに作りたかった

screep.js

コード表示

function an(){
  var html = document.getElementsByTagName('html');
  console.log(html);
}
an();

firefoxのコンソールログでscreepを検索条件に入力すると見易い。自分のサイトをスクレイピングの犠牲にする。

あとがき

スクレイピングっておもしろい。練習は自分のサイトをlocalhostに落としてからやればよさそう。イメージどおりに練習環境つくれた。「スクレイピング 環境構築」でぐぐっていたらseleniumヒットして「ぁぁあったのか」となったけど、まぁいいか。以上、ありがとうございました。

Webスクレイピング入門

baseイメージがcentosのdockerコンテナにapacheとphpをinstallした話

参考文献

PHP + Apacheのインストール - Linux環境 - CentOS

Dockerfile

コード表示

[oracle@centos tmpp]$ cat D*
FROM centos:latest

RUN yum install -y httpd \
 yum install -y php \
 yum install -y iputils \
 yum install -y vim \
 yum install -y tree \
 yum install -y lsof \
 yum install -y net-tools \
 yum install -y psmisc \
 yum install -y bind-utils \
 yum install -y traceroute

RUN yum install -y sudo
RUN groupadd -g 1001 docker
RUN useradd -m -g docker -u 1000 php
RUN echo 'php_pwd' | passwd --stdin php
RUN echo 'root_pwd' | passwd --stdin root
RUN echo 'php ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

コンテナイメージ作成

コード表示

[oracle@centos tmpp]$ docker build -t centos_php .
[oracle@centos tmpp]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos_php          latest              f63aed230c0b        11 minutes ago      499MB
centos              latest              9f38484d220f        2 months ago        202MB

コンテナ起動

コード表示

[oracle@centos tmpp]$ docker run --privileged -p 8080:80 --name php -itd centos_php /sbin/init
9f0534a4c2661a84a0ab04bcc46aadf564d4e3a45e7d5f4979d6d99e6e2663f0
[oracle@centos tmpp]$ docker exec -it php /bin/bash
[root@9f0534a4c266 /]# whoami 
root
[root@9f0534a4c266 /]# id
uid=0(root) gid=0(root) groups=0(root)
[root@9f0534a4c266 /]# su php
[php@9f0534a4c266 /]$ whoami
php
[php@9f0534a4c266 /]$ id
uid=1000(php) gid=1001(docker) groups=1001(docker)
[php@9f0534a4c266 /]$ exit

サービス起動確認

コード表示

[root@9f0534a4c266 /]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
[root@9f0534a4c266 /]# systemctl start httpd
[root@9f0534a4c266 /]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2019-05-21 13:11:15 UTC; 22s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 2655 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /docker/9f0534a4c2661a84a0ab04bcc46aadf564d4e3a45e7d5f4979d6d99e6e2663f0/system.slice/httpd.service
           ├─2655 /usr/sbin/httpd -DFOREGROUND
           ├─2656 /usr/sbin/httpd -DFOREGROUND
           ├─2657 /usr/sbin/httpd -DFOREGROUND
           ├─2658 /usr/sbin/httpd -DFOREGROUND
           ├─2659 /usr/sbin/httpd -DFOREGROUND
           └─2660 /usr/sbin/httpd -DFOREGROUND
           ‣ 2655 /usr/sbin/httpd -DFOREGROUND

May 21 13:11:15 9f0534a4c266 systemd[1]: Starting The Apache HTTP Server...
May 21 13:11:15 9f0534a4c266 httpd[2655]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
May 21 13:11:15 9f0534a4c266 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@9f0534a4c266 /]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@9f0534a4c266 /]# systemctl list-unit-files  -t service | grep httpd
httpd.service                          enabled 

サービスポート確認

コード表示

[root@9f0534a4c266 /]# netstat -apn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2655/httpd          
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  2      [ ACC ]     STREAM     LISTENING     418581536 1/init               /run/dbus/system_bus_socket
unix  3      [ ]         DGRAM                    418574907 1/init               /run/systemd/notify
unix  2      [ ]         DGRAM                    418574909 1/init               /run/systemd/cgroups-agent
unix  2      [ ACC ]     STREAM     LISTENING     418574911 1/init               /run/systemd/private
unix  2      [ ]         DGRAM                    418574933 1/init               /run/systemd/shutdownd
unix  2      [ ACC ]     STREAM     LISTENING     418574935 1/init               /run/systemd/journal/stdout
unix  5      [ ]         DGRAM                    418574938 1/init               /run/systemd/journal/socket
unix  3      [ ]         DGRAM                    418574940 1/init               /dev/log
unix  2      [ ACC ]     SEQPACKET  LISTENING     418574945 1/init               /run/udev/control
unix  2      [ ]         DGRAM                    418578316 945/systemd-logind   
unix  3      [ ]         STREAM     CONNECTED     418578273 840/dbus-daemon      
unix  3      [ ]         STREAM     CONNECTED     418581590 1/init               /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     418585610 945/systemd-logind   
unix  2      [ ]         DGRAM                    418779510 2662/login           
unix  3      [ ]         STREAM     CONNECTED     418578323 945/systemd-logind   
unix  3      [ ]         STREAM     CONNECTED     418539486 840/dbus-daemon      /run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    418579835 17/systemd-journald  
unix  3      [ ]         STREAM     CONNECTED     418578274 840/dbus-daemon      
unix  3      [ ]         STREAM     CONNECTED     418561423 1/init               /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     418581547 1/init               
unix  3      [ ]         STREAM     CONNECTED     418731316 1/init               /run/systemd/journal/stdout
unix  3      [ ]         DGRAM                    418573011 30/systemd-udevd     
unix  3      [ ]         STREAM     CONNECTED     418578275 840/dbus-daemon      /run/dbus/system_bus_socket
unix  3      [ ]         DGRAM                    418573010 30/systemd-udevd     
unix  3      [ ]         STREAM     CONNECTED     418574327 840/dbus-daemon      
unix  3      [ ]         STREAM     CONNECTED     418581552 1/init               /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     418722808 2655/httpd           
unix  2      [ ]         DGRAM                    418572958 30/systemd-udevd     
unix  2      [ ]         DGRAM                    418780208 1/init               
unix  3      [ ]         STREAM     CONNECTED     418573667 30/systemd-udevd     
[root@9f0534a4c266 /]# lsof -i
COMMAND  PID   USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
httpd   2655   root    3u  IPv4 418727592      0t0  TCP *:http (LISTEN)
httpd   2656 apache    3u  IPv4 418727592      0t0  TCP *:http (LISTEN)
httpd   2657 apache    3u  IPv4 418727592      0t0  TCP *:http (LISTEN)
httpd   2658 apache    3u  IPv4 418727592      0t0  TCP *:http (LISTEN)
httpd   2659 apache    3u  IPv4 418727592      0t0  TCP *:http (LISTEN)
httpd   2660 apache    3u  IPv4 418727592      0t0  TCP *:http (LISTEN)
[root@9f0534a4c266 /]# pstree -p
systemd(1)-+-dbus-daemon(840)
           |-httpd(2655)-+-httpd(2656)
           |             |-httpd(2657)
           |             |-httpd(2658)
           |             |-httpd(2659)
           |             `-httpd(2660)
           |-login(2686)
           |-systemd-journal(17)
           |-systemd-logind(945)
           `-systemd-udevd(30)

http動作確認

localhost

コード表示

[root@9f0534a4c266 html]# curl localhost:80 | grep h1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4897  .jumbotron h1 {
100  4   	  <h1>Testing 123..</h1>
897    0     0  4073k      0 --:--:-- --:--:-- --:--:-- 4782k

ブラウザから。コマンドラインからは外部に公開していないポートなのでエラー。

コード表示

[root@9f0534a4c266 /]# curl http://localhost:8080/
curl: (7) Failed to connect to ::1: Network is unreachable

phpバージョン確認

いんすこはできていそう

コード表示

[root@9f0534a4c266 /]# php -v
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

phpファイルつくってみる

コード表示

[root@9f0534a4c266 /]# cd /var/www/html
[root@9f0534a4c266 html]# vi info.php
[root@9f0534a4c266 html]# cat info.php

[root@9f0534a4c266 html]# ll
total 4
-rw-r--r--. 1 root root 20 May 21 13:24 info.php
[root@9f0534a4c266 html]# curl http://localhost:8080/info.php
curl: (7) Failed to connect to ::1: Network is unreachable
[root@9f0534a4c266 html]# curl http://localhost:80/info.php | grep title
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<title>phpinfo()</title><meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" /></head>
100 41766    0 41766    0     0  5159k      0 --:--:-- --:--:-- --:--:-- 5826k

formも簡単につくれるんだ

コード表示

[root@9f0534a4c266 html]# cat form.php
<html>
  <head>
  </head>
  <body>
    <form method="POST" action="show.php">
      <label>please input name</label>
      <input type="text" name="name"/><br/>
      <label>please input mailaddress</label>
      <input type="text" name="mail"/>
      <input type="submit" value="submit"/>
    </form>
  </body>
</html>
[root@9f0534a4c266 html]# vi form.php
[root@9f0534a4c266 html]# ll
total 8
-rw-r--r--. 1 root root 320 May 21 13:39 form.php
-rw-r--r--. 1 root root  20 May 21 13:24 info.php
[root@9f0534a4c266 html]# curl localhost:80/form.php
<html>
  <head>
  </head>
  <body>
    <form method="POST" action="show.php">
      <label>please input name</label>
      <input type="text" name="name"/><br/>
      <label>please input mailaddress</label>
      <input type="text" name="mail"/>
      <input type="submit" value="submit"/>
    </form>
  </body>
</html>
[root@9f0534a4c266 html]# curl localhost:8080/form.php
curl: (7) Failed to connect to ::1: Network is unreachable

フォーワーディングもできるんだな

コード表示

[root@9f0534a4c266 html]# cat show.php
<html>
  <head>
  </head>
  <body>
    <?php
      echo $_POST["name"] ."kuraine". $_POST["mail"] ."mujiku";
    ?>
  </body>
</html>


json.php

コード表示

[root@9f0534a4c266 html]# cat json.php
<?php
  $json_string = file_get_contents('php://input');
  echo $json_string;
  $obj = json_decode($json_string);
  var_dump($obj);
?>
[root@9f0534a4c266 html]# curl -H "Content-Type: application/json" -X POST http://localhost:80/json.php -d '{"name":"aine","mail":"nahato"}'
{"name":"aine","mail":"nahato"}object(stdClass)#1 (2) {
  ["name"]=>
  string(4) "aine"
  ["mail"]=>
  string(6) "nahato"
}
[root@9f0534a4c266 html]# curl -H "Content-Type: application/json" -X POST http://localhost:8080/json.php -d '{"name":"aine","mail":"nahato"}'
curl: (7) Failed to connect to ::1: Network is unreachable

ログとか

ブラウザからアクセスすると172.17.0.1なのか。curlだと127.0.0.1。

コード表示

[root@9f0534a4c266 httpd]# tail -f /var/log/httpd/access_log
172.17.0.1 - - [21/May/2019:21:57:11 +0000] "POST /show.php HTTP/1.1" 200 80 "http://localhost:8080/form.php" "Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0"
127.0.0.1 - - [21/May/2019:21:57:35 +0000] "POST /json.php HTTP/1.1" 200 124 "-" "curl/7.29.0"
[oracle@centos tmpp]$ ip a show docker0
3: docker0:  mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:35:00:60:61 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:35ff:fe00:6061/64 scope link 
       valid_lft forever preferred_lft forever

[oracle@centos tmpp]$ sudo iptables -t nat -L -n | grep -A 10 "Chain POSTROUTING"
[sudo] oracle のパスワード:
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0           
RETURN     all  --  192.168.122.0/24     224.0.0.0/24        
RETURN     all  --  192.168.122.0/24     255.255.255.255     
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    

apacheとtomcatをdockerコンテナで作って,ajp連携できるようにした話。

参考文献

なんとなくわかる。なんかのアイディアにつかえそう。

Dockerfileを並列に結ぶコマンドを作りたい(作った?)  

Docker ARGコマンドすげぇつかえそう

Dockerfile ARG入門  
Docker Compose - docker-compose.yml リファレンス  
DockerでTomcatとNginxの構築をやってみた  
Proxy Support HOW-TO  
Apache モジュール mod_proxy  
よく見るHTTPステータスコード一覧とその意味を理解する  
Apache のリバースプロキシの設定方法  
Apache httpd と Tomcat を連携させる方法  
Apache 2.4 で リバースプロキシの設定  

ディレクトリ構成

コード表示

[oracle@centos tmp]$ tree
.
├── app
│   ├── ap
│   │   ├── Dockerfile
│   │   ├── kick.sh
│   │   └── mig
│   │       ├── cfg
│   │       │   ├── env.sh
│   │       │   └── inst.sh
│   │       ├── exe
│   │       │   └── pre.sh
│   │       └── src
│   │           └── index.html
│   ├── db
│   └── web
│       ├── Dockerfile
│       ├── kick.sh
│       └── mig
│           ├── cfg
│           │   ├── env.sh
│           │   └── inst.sh
│           ├── exe
│           │   └── pre.sh
│           └── src
│               └── index.html
└── docker-compose.yml

12 directories, 13 files

Dockerfile

ap側

コード表示

[oracle@centos tmp]$ cat $(find ./app/ap -name "D*")
FROM centos:latest

ENV TZ='Asia/Tokyo'

ENV MNT_DIR=/mnt
ENV MIG_DIR=./mig
ENV CFG_DIR=${MNT_DIR}/cfg
ENV EXE_DIR=${MNT_DIR}/exe
ENV TAR_DIR=/mnt

COPY ${MIG_DIR}/ ${MNT_DIR}/

RUN source ${CFG_DIR}/*.sh

RUN find ${TAR_DIR} -name "*.sh"
RUN chmod u+x ${CFG_DIR}/*.sh && find ${CFG_DIR} -name "*.sh" | while read line;do bash -c ${line};done
RUN chmod u+x ${EXE_DIR}/*.sh && find ${EXE_DIR} -name "*.sh" | while read line;do bash -c ${line};done

RUN sed -i -e 's/.*<role rolename="admin-gui"\/>.*/<role rolename="admin-gui"\/>/' /usr/share/tomcat/conf/tomcat-users.xml
RUN sed -i -e 's/.*<role rolename="manager-gui"\/>.*/<role rolename="manager-gui"\/>/' /usr/share/tomcat/conf/tomcat-users.xml
RUN sed -i -e 's/.*<user name="admin".*/<user name="admin" password="tomcat" roles="admin-gui,manager-gui"\/>/' /usr/share/tomcat/conf/tomcat-users.xml

EXPOSE 8080
CMD ["/sbin/init"]

web側

コード表示

[oracle@centos tmp]$ cat $(find ./app/web -name "D*")
FROM centos:latest

ENV TZ='Asia/Tokyo'

ENV MNT_DIR=/mnt
ENV MIG_DIR=./mig
ENV CFG_DIR=${MNT_DIR}/cfg
ENV EXE_DIR=${MNT_DIR}/exe
ENV WEB_SRC_DIR=${MIG_DIR}/src
ENV AP_SRC_DIR=${MNT_DIR}/src/ap
ENV TAR_DIR=/mnt

COPY ${MIG_DIR}/ ${MNT_DIR}/

RUN source ${CFG_DIR}/*.sh

COPY ${WEB_SRC_DIR}/*.html ${WEB_TAR_DIR}/
 
RUN find ${TAR_DIR} -name "*.sh"

RUN chmod u+x ${CFG_DIR}/*.sh && find ${CFG_DIR} -name "*.sh" | while read line;do bash -c ${line};done
RUN chmod u+x ${EXE_DIR}/*.sh && find ${EXE_DIR} -name "*.sh" | while read line;do bash -c ${line};done

EXPOSE 80
CMD ["/sbin/init"]

kick.sh

apとwebで差はない。コレ一つにまとめるスクリプトつくれそうだけど、、まだできていない。

コード表示

[oracle@centos tmp]$ diff $(echo $(find ./app/ -name "kic*"))
[oracle@centos tmp]$ cat $(find ./app/web -name "kic*")
WK_PATH=$0
EXE_PATH=$(pwd)${WK_PATH#.}
IMAGE_NAME=$1

if [ -z "${IMAGE_NAME}" ]; then
cat <<EOF
_________________________________________________________________________________
please enter build image name.

EOF
  exit 1
fi

echo "Building image '${IMAGE_NAME}' ..."

BUILD_START=$(date '+%s')
( cd ${EXE_PATH%/*};docker build --force-rm=true --no-cache=true -t ${IMAGE_NAME} -f Dockerfile . || {
  echo 'there was an error building the image.'
  exit 1
} )
BUILD_END=$(date '+%s')
BUILD_ELAPSED=$((${BUILD_END}-${BUILD_START}))

echo ''

if [ $? -eq 0 ]; then
cat <<EOF
_________________________________________________________________________________

-->${IMAGE_NAME} was built

Build completed in ${BUILD_ELAPSED} seconds.

EOF

else
  echo 'docker image was NOT successfully created'
fi

env.sh

空っぽ。ちなみに試したけど、外部ファイルの環境変数ENVコマンド以外で指定できないぽいから、除外対象ファイルとか除外文言とか定義したりして活用する見込み。

コード表示

[oracle@centos tmp]$ diff $(echo $(find ./app/ -name "env*"))
[oracle@centos tmp]$ cat $(find ./app/web -name "env*")
#!/bin/bash

inst.sh

ap側

コード表示

[oracle@centos tmp]$ cat $(find ./app/ap -name "inst*")
#!/bin/bash
yum install -y tar \ 
yum install -y curl \ 
yum install -y iputils \
yum install -y net-tools \
yum install -y iproute \
yum install -y vim \
yum install -y tree \
yum install -y lsof \
yum install -y tomcat \
yum install -y tomcat-webapps \
yum install -y tomcat-admin-webapps \
yum install -y tomcat-docs-webapp

web側

コード表示

[oracle@centos tmp]$ cat $(find ./app/web -name "inst*")
#!/bin/bash
yum install -y httpd \ 
yum install -y iputils \
yum install -y net-tools \
yum install -y iproute \
yum install -y vim \
yum install -y tree \
yum install -y lsof

pre.sh

このスクリプトいいよな。サブシェルでディレクトリ変えずに、マッチしないやつは消していく発想。ハンドリングも綺麗。

コード表示

[oracle@centos tmp]$ diff $(echo $(find ./app/ -name "pre*"))
[oracle@centos tmp]$ cat $(find ./app/ap -name "pre*")
#!/bin/bash
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;\
yum update -y;yum clean all;

index.html

コード表示

[oracle@centos tmp]$ diff $(echo $(find ./app/ -name "inde*"))
[oracle@centos tmp]$ cat $(find ./app/ap -name "inde*")
<html>
    <head>
        <title>Test Page</title>
    </head>
    <body>
        <p>This is a test.</p>
    </body>
</html>

docker-compose.yml

bashかけるんだったら、うまいことやってやろうとしたけど。そう簡単に甘くない。上書きされたりされなかったりがめんどくさいんだよな。8009ポートは外部からアクセスする必要ないので、portsではなく、expose。

コード表示

[oracle@centos tmp]$ cat $(find ./ -name "*com*")
version: '3'
services:
  apache:
    image: apache
    container_name: apa
    #command: bash -c "echo hoge"
    privileged: true
    ports:
      - '8080:80'
  tomcat:
    image: tomcat
    container_name: tom
    #command: bash -c "echo hoge"
    privileged: true
    ports:
      - '8081:8080'
    expose:
      - '8009'

dockerイメージ作成

コード表示

[oracle@centos tmp]$ bash $(find ./app/ap -name "kic*") tomcat
[oracle@centos tmp]$ bash $(find ./app/web -name "kic*") apache
[oracle@centos tmp]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
apache              latest              31ede815a512        2 minutes ago       503MB
tomcat              latest              6f8507eb4e71        4 minutes ago       681MB
centos              latest              9f38484d220f        6 weeks ago         202MB

コンテナ起動前、ブリッジ接続ルータ確認

コード表示

[oracle@centos tmp]$ brctl show
bridge name	bridge id		STP enabled	interfaces
docker0		8000.0242bccfb016	no		
virbr0		8000.5254006a2171	yes		virbr0-nic

コンテナ起動前、ip確認

コード表示

[oracle@centos tmp]$ ip a show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:d8:61:2c:f1:5b brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.109/24 brd 192.168.1.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ccc0:20d4:3aed:ca75/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:6a:21:71 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:6a:21:71 brd ff:ff:ff:ff:ff:ff
5: docker0:  mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:bc:cf:b0:16 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:bcff:fecf:b016/64 scope link 
       valid_lft forever preferred_lft forever

コンテナ起動前、ipマスカレ確認

POSTROUTING確認。一部抜粋。

コード表示

[oracle@centos tmp]$ sudo iptables -t nat -L -n
[sudo] oracle のパスワード:
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0           
RETURN     all  --  192.168.122.0/24     224.0.0.0/24        
RETURN     all  --  192.168.122.0/24     255.255.255.255     
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    
POSTROUTING_direct  all  --  0.0.0.0/0            0.0.0.0/0           
POSTROUTING_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
POSTROUTING_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           

dockerコンテナ起動

コード表示

[oracle@centos tmp]$ docker-compose down
Stopping tom ... done
Stopping apa ... done
Removing tom ... done
Removing apa ... done
Removing network tmp_default
[oracle@centos tmp]$ docker-compose up -d
Creating network "tmp_default" with the default driver
Creating apa ... done
Creating tom ... done
[oracle@centos tmp]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                              NAMES
c2b460acbc07        tomcat              "/sbin/init"        54 seconds ago      Up 53 seconds       8009/tcp, 0.0.0.0:8081->8080/tcp   tom
61eff46d2318        apache              "/sbin/init"        54 seconds ago      Up 53 seconds       0.0.0.0:8080->80/tcp               apa

コンテナ起動後、ブリッジ確認

コード表示

[oracle@centos tmp]$ brctl show
bridge name	bridge id		STP enabled	interfaces
br-e1cb1ad75561		8000.02424a058b14	no		veth027f014
							veth2c1ba96
docker0		8000.0242bccfb016	no		
virbr0		8000.5254006a2171	yes		virbr0-nic

コンテナ起動後、ip確認

docker-composeだとデフォルトでbridge接続のルータできるんだな。出来たルータにコンテナのケーブルが刺さっている。

コード表示

[oracle@centos tmp]$ ip a show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:d8:61:2c:f1:5b brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.109/24 brd 192.168.1.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::ccc0:20d4:3aed:ca75/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0:  mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:6a:21:71 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic:  mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:6a:21:71 brd ff:ff:ff:ff:ff:ff
5: docker0:  mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:bc:cf:b0:16 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:bcff:fecf:b016/64 scope link 
       valid_lft forever preferred_lft forever
556: br-e1cb1ad75561:  mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:4a:05:8b:14 brd ff:ff:ff:ff:ff:ff
    inet 172.28.0.1/16 brd 172.28.255.255 scope global br-e1cb1ad75561
       valid_lft forever preferred_lft forever
    inet6 fe80::42:4aff:fe05:8b14/64 scope link 
       valid_lft forever preferred_lft forever
558: veth2c1ba96@if557:  mtu 1500 qdisc noqueue master br-e1cb1ad75561 state UP group default 
    link/ether fa:07:e3:4e:8e:3a brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::f807:e3ff:fe4e:8e3a/64 scope link 
       valid_lft forever preferred_lft forever
560: veth027f014@if559:  mtu 1500 qdisc noqueue master br-e1cb1ad75561 state UP group default 
    link/ether d6:cf:3d:b9:7e:73 brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::d4cf:3dff:feb9:7e73/64 scope link 
       valid_lft forever preferred_lft forever

docker network確認

tmp_default以外はデフぉである。composeでできたということ。

コード表示

[oracle@centos tmp]$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
73a8404b71c6        bridge              bridge              local
ad2f99e1e398        host                host                local
4d1d8a2fc9da        none                null                local
e1cb1ad75561        tmp_default         bridge              local

コンテナに割り当てられたip確認

コード表示

[oracle@centos tmp]$ docker network inspect $(docker network ls -q) | grep -E "Subnet|Name|IPv4|G"
        "Name": "bridge",
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
        "Name": "host",
        "Name": "none",
        "Name": "tmp_default",
                    "Subnet": "172.28.0.0/16",
                    "Gateway": "172.28.0.1"
                "Name": "apa",
                "IPv4Address": "172.28.0.2/16",
                "Name": "tom",
                "IPv4Address": "172.28.0.3/16",

コンテナ起動後、ipマスカレ確認

一部抜粋。POSTROUTINGにブリッジルータの奴が登録されている。

コード表示

[oracle@centos tmp]$ sudo iptables -t nat -L -n
[sudo] oracle のパスワード:
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  172.28.0.0/16        0.0.0.0/0           
MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0           
RETURN     all  --  192.168.122.0/24     224.0.0.0/24        
RETURN     all  --  192.168.122.0/24     255.255.255.255     
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    
POSTROUTING_direct  all  --  0.0.0.0/0            0.0.0.0/0           
POSTROUTING_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
POSTROUTING_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           
MASQUERADE  tcp  --  172.28.0.2           172.28.0.2           tcp dpt:80
MASQUERADE  tcp  --  172.28.0.3           172.28.0.3           tcp dpt:8080

tomcatコンテナに潜る

server.xmlのポート確認。未使用ポートになりうる、8080はクローズしておく本来は。今回は開けっぱで。

コード表示

[root@c2b460acbc07 /]# cp /etc/tomcat/{,org_}server.xml
cp: overwrite '/etc/tomcat/org_server.xml'? y
[root@c2b460acbc07 /]# diff /etc/tomcat/{,org_}server.xml
[root@c2b460acbc07 /]# cat ./etc/tomcat/server.xml | grep -A 10 "Connector port="
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">

webappsでググる。ここらのフォルダは削除してあらたに作っていってもいいんだよな。そっちの方がすっきりする。参考程度のコンテナきってもいいし。何かモノ作る時には削除しよう。web.xmlも大事だ。

コード表示

[root@c2b460acbc07 /]# find . -name "*webapps*"
./usr/share/tomcat/webapps
./var/lib/yum/yumdb/t/6343923fac93857eecb0cd7fd4ff8015ec401c66-tomcat-admin-webapps-7.0.76-9.el7_6-noarch
./var/lib/yum/yumdb/t/47c2512fc616bb948c785d40da7093e19239019d-tomcat-webapps-7.0.76-9.el7_6-noarch
./var/lib/tomcat/webapps
[root@c2b460acbc07 /]# diff -r /usr/share/tomcat/webapps /var/lib/tomcat/webapps
[root@c2b460acbc07 /]# ll /usr/share/tomcat/webapps
lrwxrwxrwx. 1 root tomcat 23 Apr 30 22:17 /usr/share/tomcat/webapps -> /var/lib/tomcat/webapps
[root@c2b460acbc07 /]# ll /var/lib/tomcat/webapps
total 24
drwxr-xr-x.  3 tomcat tomcat 4096 Apr 30 22:17 ROOT
drwxr-xr-x. 14 root   root   4096 Apr 30 22:17 docs
drwxr-xr-x.  8 tomcat tomcat 4096 Apr 30 22:17 examples
drwxr-xr-x.  5 root   tomcat 4096 Apr 30 22:17 host-manager
drwxr-xr-x.  5 root   tomcat 4096 Apr 30 22:17 manager
drwxr-xr-x.  5 tomcat tomcat 4096 Apr 30 22:17 sample
[root@c2b460acbc07 /]# find . -name "*web.xml*"
./usr/share/mime/application/vnd.oasis.opendocument.text-web.xml
./var/lib/tomcat/webapps/ROOT/WEB-INF/web.xml
./var/lib/tomcat/webapps/sample/WEB-INF/web.xml
./var/lib/tomcat/webapps/host-manager/WEB-INF/web.xml
./var/lib/tomcat/webapps/manager/WEB-INF/web.xml
./var/lib/tomcat/webapps/examples/WEB-INF/web.xml
./var/lib/tomcat/webapps/docs/appdev/web.xml.txt
./var/lib/tomcat/webapps/docs/appdev/sample/web/WEB-INF/web.xml
./var/lib/tomcat/webapps/docs/WEB-INF/web.xml
./etc/tomcat/web.xml

サービス起動

コード表示

[root@c2b460acbc07 /]# systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
[root@c2b460acbc07 /]# systemctl start tomcat
[root@c2b460acbc07 /]# systemctl status tomcat
● tomcat.service - Apache Tomcat Web Application Container
   Loaded: loaded (/usr/lib/systemd/system/tomcat.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-01 15:16:50 JST; 1s ago
 Main PID: 5725 (java)
   CGroup: /docker/c2b460acbc0728e00a4443375d97e70d4caebdb487aa3a54538f78fc06f4932f/system.slice/tomcat.service
           └─5725 /usr/lib/jvm/jre/bin/java -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat -Dcatalina...
           ‣ 5725 /usr/lib/jvm/jre/bin/java -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat -Dcatalina...

May 01 15:16:51 c2b460acbc07 server[5725]: May 01, 2019 6:16:51 AM org.apache.catalina.startup.TldConfig execute
May 01 15:16:51 c2b460acbc07 server[5725]: INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned b...pilation time.
May 01 15:16:51 c2b460acbc07 server[5725]: May 01, 2019 6:16:51 AM org.apache.catalina.startup.HostConfig deployDirectory
May 01 15:16:51 c2b460acbc07 server[5725]: INFO: Deployment of web application directory /var/lib/tomcat/webapps/docs has finished in 114 ms
May 01 15:16:51 c2b460acbc07 server[5725]: May 01, 2019 6:16:51 AM org.apache.coyote.AbstractProtocol start
May 01 15:16:51 c2b460acbc07 server[5725]: INFO: Starting ProtocolHandler ["http-bio-8080"]
May 01 15:16:51 c2b460acbc07 server[5725]: May 01, 2019 6:16:51 AM org.apache.coyote.AbstractProtocol start
May 01 15:16:51 c2b460acbc07 server[5725]: INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 01 15:16:51 c2b460acbc07 server[5725]: May 01, 2019 6:16:51 AM org.apache.catalina.startup.Catalina start
May 01 15:16:51 c2b460acbc07 server[5725]: INFO: Server startup in 955 ms
Hint: Some lines were ellipsized, use -l to show in full.
[root@c2b460acbc07 /]# lsof -i:8009 -i:8080 -P
COMMAND  PID   USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
java    5725 tomcat   49u  IPv4 670144588      0t0  TCP *:8080 (LISTEN)
java    5725 tomcat   50u  IPv4 670144589      0t0  TCP *:8009 (LISTEN)

apacheにもぐる

noindexでぐぐると、デフぉ頁のふぁいるでてくる。ちなみに/var/www/htmlにファイル置いているとtomcatのデフォルトページがでないんだね。

コード表示

[oracle@centos ~]$ docker exec -it apa /bin/bash
[root@61eff46d2318 /]# find / -name "*noindex*"
/usr/share/httpd/noindex
[root@61eff46d2318 /]# cd /usr/share/httpd/noindex
[root@61eff46d2318 noindex]# ll
total 16
drwxr-xr-x. 3 root root 4096 Apr 30 22:19 css
drwxr-xr-x. 2 root root 4096 Apr 30 22:19 images
-rw-r--r--. 1 root root 4897 Oct 16  2014 index.html
[root@61eff46d2318 noindex]# cd ..
[root@61eff46d2318 httpd]# ll
total 12
drwxr-xr-x. 3 root root 4096 Apr 30 22:19 error
drwxr-xr-x. 3 root root 4096 Apr 30 22:19 icons
drwxr-xr-x. 4 root root 4096 Apr 30 22:19 noindex

asobu。起動したりすれば、staticなページをcurlで標準出力したりできる。

コード表示

[root@61eff46d2318 httpd]# cd /var/www/html
[root@61eff46d2318 html]# ll 
total 0
[oracle@centos ~]$ docker exec -it apa /bin/bash
[root@61eff46d2318 /]# cd /var/www/html
[root@61eff46d2318 html]# cat <<ROD >index.html
> <html>
>     <head>
>         <title>Test Page</title>
>     </head>
>     <body>
>         <p>ainekurainenahatomujiku</p>
>     </body>
> </html>
> ROD
[root@61eff46d2318 html]# cat ind*
<html>
    <head>
        <title>Test Page</title>
    </head>
    <body>
        <p>ainekurainenahatomujiku</p>
    </body>
</html>
[root@61eff46d2318 html]# ll
total 4
-rw-r--r--. 1 root root 133 May  1 15:21 index.html
[root@61eff46d2318 html]# mkdir -p {aine,kuraine,nahato,mujiku}
[root@61eff46d2318 html]# tree
.
|-- aine
|-- index.html
|-- kuraine
|-- mujiku
`-- nahato

4 directories, 1 file
[root@61eff46d2318 html]# printf '%s\n' {aine,kuraine,nahato,mujiku} | xargs -I@ bash -c 'echo cp index.html @'
cp index.html aine
cp index.html kuraine
cp index.html nahato
cp index.html mujiku
[root@61eff46d2318 html]# printf '%s\n' {aine,kuraine,nahato,mujiku} | xargs -I@ bash -c 'cp index.html @'
[root@61eff46d2318 html]# tree
.
|-- aine
|   `-- index.html
|-- index.html
|-- kuraine
|   `-- index.html
|-- mujiku
|   `-- index.html
`-- nahato
    `-- index.html

4 directories, 5 files
[root@61eff46d2318 html]# ll
total 36
drwxr-xr-x. 2 root root 4096 May  1 15:22 aine
-rw-r--r--. 1 root root  133 May  1 15:21 index.html
drwxr-xr-x. 2 root root 4096 May  1 15:22 kuraine
drwxr-xr-x. 2 root root 4096 May  1 15:22 mujiku
drwxr-xr-x. 2 root root 4096 May  1 15:22 nahato
[root@61eff46d2318 html]# printf '%s\n' 'http://192.168.1.109:8080/'{aine,kuraine,nahato,mujiku}'/index.html'
http://192.168.1.109:8080/aine/index.html
http://192.168.1.109:8080/kuraine/index.html
http://192.168.1.109:8080/nahato/index.html
http://192.168.1.109:8080/mujiku/index.html
[root@61eff46d2318 html]# printf '%s\n' 'curl -v http://192.168.1.109:8080/'{aine,kuraine,nahato,mujiku}'/index.html' | xargs -I@ bash -c '@'
* About to connect() to 192.168.1.109 port 8080 (#0)
*   Trying 192.168.1.109...
* No route to host
* Failed connect to 192.168.1.109:8080; No route to host
* Closing connection 0
curl: (7) Failed connect to 192.168.1.109:8080; No route to host
* About to connect() to 192.168.1.109 port 8080 (#0)
*   Trying 192.168.1.109...
* No route to host
* Failed connect to 192.168.1.109:8080; No route to host
* Closing connection 0
curl: (7) Failed connect to 192.168.1.109:8080; No route to host
* About to connect() to 192.168.1.109 port 8080 (#0)
*   Trying 192.168.1.109...
* No route to host
* Failed connect to 192.168.1.109:8080; No route to host
* Closing connection 0
curl: (7) Failed connect to 192.168.1.109:8080; No route to host
* About to connect() to 192.168.1.109 port 8080 (#0)
*   Trying 192.168.1.109...
* No route to host
* Failed connect to 192.168.1.109:8080; No route to host
* Closing connection 0
curl: (7) Failed connect to 192.168.1.109:8080; No route to host

httpd.confに追加

脱線したけど、これが大切。ipはdockerコンテナのapaにallocateされているip。

コード表示

[root@61eff46d2318 /]# cp /etc/httpd/conf/{,org_}httpd.conf
[root@61eff46d2318 /]# diff /etc/httpd/conf/{,org_}httpd.conf
[root@61eff46d2318 /]# vi /etc/httpd/conf/httpd.conf
[root@61eff46d2318 /]# diff /etc/httpd/conf/{,org_}httpd.conf
354,356d353
< ProxyRequests Off
< ProxyPass / ajp://172.28.0.3/
< ProxyPassReverse / ajp://172.28.0.3/

httpdサービス起動

コード表示

[root@61eff46d2318 /]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
[root@61eff46d2318 /]# systemctl start httpd.service
[root@61eff46d2318 /]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-01 15:30:03 JST; 1s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 5954 (httpd)
   Status: "Processing requests..."
   CGroup: /docker/61eff46d23187594f7efef2c6d7dee336011a869d9c014c8144a8b2d35290783/system.slice/httpd.service
           ├─5954 /usr/sbin/httpd -DFOREGROUND
           ├─5955 /usr/sbin/httpd -DFOREGROUND
           ├─5956 /usr/sbin/httpd -DFOREGROUND
           ├─5957 /usr/sbin/httpd -DFOREGROUND
           ├─5958 /usr/sbin/httpd -DFOREGROUND
           └─5959 /usr/sbin/httpd -DFOREGROUND
           ‣ 5954 /usr/sbin/httpd -DFOREGROUND

May 01 15:30:03 61eff46d2318 systemd[1]: Starting The Apache HTTP Server...
May 01 15:30:03 61eff46d2318 httpd[5954]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.28.0.2. Set the 'ServerName' directive globally to suppress this message
May 01 15:30:03 61eff46d2318 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.

ブラウザから確認。それぞれ同じ画面が出ていればOK。

tomcatのほう。managerはユーザー名とパスワードはtomcat/adminかな

コード表示

http://192.168.1.109:8081/docs
http://192.168.1.109:8081/sample
http://192.168.1.109:8081/example
http://192.168.1.109:8081/manager/html

apacheのほう

コード表示

http://192.168.1.109:8080/docs
http://192.168.1.109:8080/sample
http://192.168.1.109:8080/example
http://192.168.1.109:8080/manager/html

ログ確認。apacheにもtomcatにも同じログでているね。

tomcat側

コード表示

[root@c2b460acbc07 /]# find /var -name "*log*"
/var/lib/systemd/catalog
/var/lib/yum/yumdb/a/0be125f712efee4727af884ffa4a21b3d366a71e-avalon-logkit-2.1-14.el7-noarch
/var/lib/yum/yumdb/a/e6cbbc5407023b2bee22d34231a4266b69d0ea4c-apache-commons-logging-1.1.2-7.el7-noarch
/var/lib/yum/yumdb/l/fcb0a245a2d3b4e92b76136762f22caf2e7fe5f7-log4j-1.2.17-16.el7_4-noarch
/var/lib/tomcat/webapps/ROOT/asf-logo-wide.svg
/var/lib/tomcat/webapps/host-manager/images/asf-logo.svg
/var/lib/tomcat/webapps/manager/images/asf-logo.svg
/var/lib/tomcat/webapps/examples/jsp/security/protected/login.jsp
/var/lib/tomcat/webapps/examples/jsp/security/protected/login.jsp.html
/var/lib/tomcat/webapps/examples/jsp/cal/login.html
/var/lib/tomcat/webapps/examples/servlets/chat/login.jsp
/var/lib/tomcat/webapps/examples/servlets/chat/login.jsp.html
/var/lib/tomcat/webapps/docs/images/asf-logo.svg
/var/lib/tomcat/webapps/docs/logging.html
/var/lib/tomcat/webapps/docs/changelog.html
/var/log
/var/log/yum.log
/var/log/lastlog
/var/log/tallylog
/var/log/tomcat/catalina.2019-05-01.log
/var/log/tomcat/localhost.2019-05-01.log
/var/log/tomcat/localhost_access_log.2019-05-01.txt
/var/log/tomcat/manager.2019-05-01.log
/var/log/tomcat/host-manager.2019-05-01.log
[root@c2b460acbc07 /]# tail -f /var/log/tomcat/localhost_access_log.2019-05-01.txt
192.168.1.109 - - [01/May/2019:06:34:19 +0000] "GET / HTTP/1.1" 200 11217
192.168.1.109 - - [01/May/2019:06:37:33 +0000] "GET /docs HTTP/1.1" 302 -
192.168.1.109 - - [01/May/2019:06:37:33 +0000] "GET /docs/ HTTP/1.1" 304 -
192.168.1.109 - - [01/May/2019:06:46:18 +0000] "GET / HTTP/1.1" 200 11197
192.168.1.109 - - [01/May/2019:06:46:32 +0000] "GET /docs HTTP/1.1" 302 -
192.168.1.109 - - [01/May/2019:06:46:39 +0000] "GET /docs/introduction.html HTTP/1.1" 200 15227
192.168.1.109 - - [01/May/2019:06:46:42 +0000] "GET /docs/jndi-resources-howto.html HTTP/1.1" 200 58181
192.168.1.109 - - [01/May/2019:06:46:43 +0000] "GET /docs/manager-howto.html HTTP/1.1" 200 80158
192.168.1.109 - - [01/May/2019:06:46:43 +0000] "GET /docs/jasper-howto.html HTTP/1.1" 200 26829
192.168.1.109 - - [01/May/2019:06:46:44 +0000] "GET /docs/mbeans-descriptors-howto.html HTTP/1.1" 200 10795

apache側

コード表示

[root@61eff46d2318 /]# find /var -name "*log*"
/var/lib/systemd/catalog
/var/lib/yum/yumdb/c/b3f16e3c1bff41f2602b03b90e2f37b26e59400b-centos-logos-70.0.6-3.el7.centos-noarch
/var/log
/var/log/yum.log
/var/log/lastlog
/var/log/tallylog
/var/log/httpd/access_log
/var/log/httpd/error_log
[root@61eff46d2318 /]# tail -f /var/log/httpd/access_log
192.168.1.109 - - [01/May/2019:06:34:18 +0000] "-" 408 - "-" "-"
192.168.1.109 - - [01/May/2019:06:34:19 +0000] "-" 408 - "-" "-"
192.168.1.109 - - [01/May/2019:06:34:34 +0000] "GET /docs HTTP/1.1" 503 299 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:35:07 +0000] "GET /docs HTTP/1.1" 503 299 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:35:08 +0000] "GET /docs HTTP/1.1" 503 299 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:35:09 +0000] "GET /docs HTTP/1.1" 503 299 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:36:00 +0000] "-" 408 - "-" "-"
192.168.1.109 - - [01/May/2019:06:37:33 +0000] "GET /docs HTTP/1.1" 302 - "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:37:33 +0000] "GET /docs/ HTTP/1.1" 304 - "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:38:24 +0000] "-" 408 - "-" "-"
192.168.1.109 - - [01/May/2019:06:46:18 +0000] "GET / HTTP/1.1" 200 11197 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:46:32 +0000] "GET /docs HTTP/1.1" 302 - "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:46:39 +0000] "GET /docs/introduction.html HTTP/1.1" 200 15227 "http://192.168.1.109:8080/docs/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:46:42 +0000] "GET /docs/jndi-resources-howto.html HTTP/1.1" 200 58181 "http://192.168.1.109:8080/docs/introduction.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:46:43 +0000] "GET /docs/manager-howto.html HTTP/1.1" 200 80158 "http://192.168.1.109:8080/docs/jndi-resources-howto.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:46:43 +0000] "GET /docs/jasper-howto.html HTTP/1.1" 200 26829 "http://192.168.1.109:8080/docs/manager-howto.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:46:44 +0000] "GET /docs/mbeans-descriptors-howto.html HTTP/1.1" 200 10795 "http://192.168.1.109:8080/docs/jasper-howto.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [01/May/2019:06:47:30 +0000] "-" 408 - "-" "-"

dockerでapacheサービス作ろうとした話(curl attackするサーバ建てたかっただけ。)

参考文献

run引数書いていると上書きされるんだね

CMD とENTRYPOINT の違いを試してみた  
Apache HTTP Server Documentation  

Dockerfile

コード表示

[oracle@centos tmp]$ pwd
/home/oracle/tmp
[oracle@centos tmp]$ cat $(find . -name "D*")
FROM centos:latest

ENV MNT_DIR=/mnt
ENV MIG_DIR=./mig
ENV CFG_DIR=${MNT_DIR}/cfg
ENV EXE_DIR=${MNT_DIR}/exe
ENV WEB_SRC_DIR=${MIG_DIR}/src
ENV AP_SRC_DIR=${MNT_DIR}/src/ap
ENV TAR_DIR=/mnt

COPY ${MIG_DIR}/ ${MNT_DIR}/

RUN source ${CFG_DIR}/*.sh

COPY ${WEB_SRC_DIR}/*.html ${WEB_TAR_DIR}/
 
RUN find ${TAR_DIR} -name "*.sh"

RUN chmod u+x ${CFG_DIR}/*.sh && find ${CFG_DIR} -name "*.sh" | while read line;do bash -c ${line};done
RUN chmod u+x ${EXE_DIR}/*.sh && find ${EXE_DIR} -name "*.sh" | while read line;do bash -c ${line};done
EXPOSE 80
CMD ["/sbin/init"]

env.sh

設定ファイルを=で繋いだ奴とか除外対象とかていぎしたらいいとおもう。今回はない。

コード表示

[oracle@centos tmp]$ cat $(find . -name "env*")
#!/bin/bash

inst.sh

yum installはそとだし。きほん。

コード表示

[oracle@centos tmp]$ cat $(find . -name "inst*")
#!/bin/bash
yum install -y httpd \ 
yum install -y iputils \
yum install -y net-tools \
yum install -y iproute \
yum install -y vim \
yum install -y tree \
yum install -y lsof \
yum install -y traceroute

pre.sh

systemd使えるようにする奴。ただいまの最新だと、privillagedとか/sbin/initとか忘れなきゃ、普通につかえる。なにか前処理的なものを組み込んでおきたいとかは役立つかも。サービスの自動起動とか。そのサービスの自動起動がハマったんだけどね。コンテナ起こしてから起動するのはできるけど、コンテナUPしたときにサービス起動するようにしたい時、コマンド基本的に1つしか受け付けていないぽくて、&&でつなぐなりしてもExitしてたり。CMD上書きだったり、ENTRYPOINT上書きだったり。

コード表示

[oracle@centos tmp]$ cat $(find . -name "pre*")
#!/bin/bash
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;\
yum update -y;yum clean all;

index.html

See the Pen
XQQKWv
by ukijumotahaneniarukenia (@brunohigashi)
on CodePen.

kick.sh

コード表示

[oracle@centos tmp]$ cat $(find . -name "kic*")
WK_PATH=$0
EXE_PATH=$(pwd)${WK_PATH#.}
IMAGE_NAME=$1

if [ -z "${IMAGE_NAME}" ]; then
cat <<EOF
_________________________________________________________________________________
please enter build image name.

EOF
  exit 1
fi

echo "Building image '${IMAGE_NAME}' ..."

BUILD_START=$(date '+%s')
( cd ${EXE_PATH%/*};docker build --force-rm=true --no-cache=true -t ${IMAGE_NAME} -f Dockerfile . || {
  echo 'there was an error building the image.'
  exit 1
} )
BUILD_END=$(date '+%s')
BUILD_ELAPSED=$((${BUILD_END}-${BUILD_START}))

echo ''

if [ $? -eq 0 ]; then
cat <<EOF
_________________________________________________________________________________

-->${IMAGE_NAME} was built

Build completed in ${BUILD_ELAPSED} seconds.

EOF

else
  echo 'docker image was NOT successfully created'
fi

build ログ

コード表示

[oracle@centos tmp]$ bash $(find . -name "kic*") apache/httpd
Building image 'apache/httpd' ...
Sending build context to Docker daemon  10.75kB
Step 1/17 : FROM centos:latest
latest: Pulling from library/centos
8ba884070f61: Pull complete 
Digest: sha256:8d487d68857f5bc9595793279b33d082b03713341ddec91054382641d14db861
Status: Downloaded newer image for centos:latest
 ---> 9f38484d220f
Step 2/17 : ENV MNT_DIR=/mnt
 ---> Running in 629fc3fb337e
Removing intermediate container 629fc3fb337e
 ---> 4a5e68bba915
Step 3/17 : ENV MIG_DIR=./mig
 ---> Running in fb049b6cec08
Removing intermediate container fb049b6cec08
 ---> 3ede465cc893
Step 4/17 : ENV CFG_DIR=${MNT_DIR}/cfg
 ---> Running in 730023c0f16d
Removing intermediate container 730023c0f16d
 ---> 94647a1a6121
Step 5/17 : ENV EXE_DIR=${MNT_DIR}/exe
 ---> Running in 635c5c603937
Removing intermediate container 635c5c603937
 ---> 7216499d357c
Step 6/17 : ENV WEB_SRC_DIR=${MIG_DIR}/src
 ---> Running in 5bb81917ef86
Removing intermediate container 5bb81917ef86
 ---> b8aef9c6bd86
Step 7/17 : ENV WEB_TAR_DIR=/var/www/html/
 ---> Running in fa22b224fbc4
Removing intermediate container fa22b224fbc4
 ---> b89be21c121b
Step 8/17 : ENV AP_SRC_DIR=${MNT_DIR}/src/ap
 ---> Running in 1947eb1ebc25
Removing intermediate container 1947eb1ebc25
 ---> 4a4de410b234
Step 9/17 : ENV TAR_DIR=/mnt
 ---> Running in 68e8925cd16f
Removing intermediate container 68e8925cd16f
 ---> d2c301f00930
Step 10/17 : COPY ${MIG_DIR}/ ${TAR_DIR}/
 ---> a8bf32fe19f5
Step 11/17 : RUN source ${CFG_DIR}/*.sh
 ---> Running in cefd6b416e23
Removing intermediate container cefd6b416e23
 ---> 0911856bb5bc
Step 12/17 : COPY ${WEB_SRC_DIR}/*.html ${WEB_TAR_DIR}
 ---> 4a052d13ccef
Step 13/17 : RUN find ${TAR_DIR} -name "*.sh"
 ---> Running in d1b12abd8166
/mnt/cfg/inst.sh
/mnt/cfg/env.sh
/mnt/exe/pre.sh
Removing intermediate container d1b12abd8166
 ---> 6ef3c419c176
Step 14/17 : RUN chmod u+x ${CFG_DIR}/*.sh && find ${CFG_DIR} -name "*.sh" | while read line;do bash -c ${line};done
 ---> Running in e465add73fb4
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 * base: ftp-srv2.kddilabs.jp
 * extras: ftp-srv2.kddilabs.jp
 * updates: ftp-srv2.kddilabs.jp
No package   available.
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-89.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-89.el7.centos for package: httpd-2.4.6-89.el7.centos.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-89.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-89.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-89.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-89.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7_4.1 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package centos-logos.noarch 0:70.0.6-3.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-89.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch         Version                    Repository     Size
================================================================================
Installing:
 httpd              x86_64       2.4.6-89.el7.centos        updates       2.7 M
Installing for dependencies:
 apr                x86_64       1.4.8-3.el7_4.1            base          103 k
 apr-util           x86_64       1.5.2-6.el7                base           92 k
 centos-logos       noarch       70.0.6-3.el7.centos        base           21 M
 httpd-tools        x86_64       2.4.6-89.el7.centos        updates        90 k
 mailcap            noarch       2.1.41-2.el7               base           31 k

Transaction Summary
================================================================================
Install  1 Package (+5 Dependent packages)

Total download size: 24 M
Installed size: 31 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/apr-util-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for apr-util-1.5.2-6.el7.x86_64.rpm is not installed
Public key for httpd-tools-2.4.6-89.el7.centos.x86_64.rpm is not installed
--------------------------------------------------------------------------------
Total                                              3.1 MB/s |  24 MB  00:07     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) "
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7_4.1.x86_64                                   1/6 
  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/6 
  Installing : httpd-tools-2.4.6-89.el7.centos.x86_64                       3/6 
  Installing : centos-logos-70.0.6-3.el7.centos.noarch                      4/6 
  Installing : mailcap-2.1.41-2.el7.noarch                                  5/6 
  Installing : httpd-2.4.6-89.el7.centos.x86_64                             6/6 
  Verifying  : httpd-tools-2.4.6-89.el7.centos.x86_64                       1/6 
  Verifying  : mailcap-2.1.41-2.el7.noarch                                  2/6 
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  3/6 
  Verifying  : httpd-2.4.6-89.el7.centos.x86_64                             4/6 
  Verifying  : apr-1.4.8-3.el7_4.1.x86_64                                   5/6 
  Verifying  : centos-logos-70.0.6-3.el7.centos.noarch                      6/6 

Installed:
  httpd.x86_64 0:2.4.6-89.el7.centos                                            

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1                                                  
  apr-util.x86_64 0:1.5.2-6.el7                                                 
  centos-logos.noarch 0:70.0.6-3.el7.centos                                     
  httpd-tools.x86_64 0:2.4.6-89.el7.centos                                      
  mailcap.noarch 0:2.1.41-2.el7                                                 

Complete!
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ftp-srv2.kddilabs.jp
 * extras: ftp-srv2.kddilabs.jp
 * updates: ftp-srv2.kddilabs.jp
Package iputils-20160308-10.el7.x86_64 already installed and latest version
Package yum-3.4.3-161.el7.centos.noarch already installed and latest version
No package install available.
Package yum-3.4.3-161.el7.centos.noarch already installed and latest version
No package install available.
Package yum-3.4.3-161.el7.centos.noarch already installed and latest version
No package install available.
Package yum-3.4.3-161.el7.centos.noarch already installed and latest version
No package install available.
Package yum-3.4.3-161.el7.centos.noarch already installed and latest version
No package install available.
Resolving Dependencies
--> Running transaction check
---> Package iproute.x86_64 0:4.11.0-14.el7_6.2 will be installed
--> Processing Dependency: libmnl.so.0(LIBMNL_1.0)(64bit) for package: iproute-4.11.0-14.el7_6.2.x86_64
--> Processing Dependency: libxtables.so.10()(64bit) for package: iproute-4.11.0-14.el7_6.2.x86_64
--> Processing Dependency: libmnl.so.0()(64bit) for package: iproute-4.11.0-14.el7_6.2.x86_64
---> Package lsof.x86_64 0:4.87-6.el7 will be installed
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
---> Package tree.x86_64 0:1.6.0-10.el7 will be installed
---> Package vim-enhanced.x86_64 2:7.4.160-5.el7 will be installed
--> Processing Dependency: vim-common = 2:7.4.160-5.el7 for package: 2:vim-enhanced-7.4.160-5.el7.x86_64
--> Processing Dependency: which for package: 2:vim-enhanced-7.4.160-5.el7.x86_64
--> Processing Dependency: perl(:MODULE_COMPAT_5.16.3) for package: 2:vim-enhanced-7.4.160-5.el7.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 2:vim-enhanced-7.4.160-5.el7.x86_64
--> Processing Dependency: libgpm.so.2()(64bit) for package: 2:vim-enhanced-7.4.160-5.el7.x86_64
--> Running transaction check
---> Package gpm-libs.x86_64 0:1.20.7-5.el7 will be installed
---> Package iptables.x86_64 0:1.4.21-28.el7 will be installed
--> Processing Dependency: libnfnetlink.so.0()(64bit) for package: iptables-1.4.21-28.el7.x86_64
--> Processing Dependency: libnetfilter_conntrack.so.3()(64bit) for package: iptables-1.4.21-28.el7.x86_64
---> Package libmnl.x86_64 0:1.0.3-7.el7 will be installed
---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
---> Package vim-common.x86_64 2:7.4.160-5.el7 will be installed
--> Processing Dependency: vim-filesystem for package: 2:vim-common-7.4.160-5.el7.x86_64
---> Package which.x86_64 0:2.20-7.el7 will be installed
--> Running transaction check
---> Package libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3 will be installed
---> Package libnfnetlink.x86_64 0:1.0.1-4.el7 will be installed
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
---> Package vim-filesystem.x86_64 2:7.4.160-5.el7 will be installed
--> Running transaction check
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
--> Running transaction check
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: groff-base for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package groff-base.x86_64 0:1.22.2-8.el7 will be installed
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch     Version                      Repository
                                                                           Size
================================================================================
Installing:
 iproute                  x86_64   4.11.0-14.el7_6.2            updates   764 k
 lsof                     x86_64   4.87-6.el7                   base      331 k
 net-tools                x86_64   2.0-0.24.20131004git.el7     base      306 k
 tree                     x86_64   1.6.0-10.el7                 base       46 k
 vim-enhanced             x86_64   2:7.4.160-5.el7              base      1.0 M
Installing for dependencies:
 gpm-libs                 x86_64   1.20.7-5.el7                 base       32 k
 groff-base               x86_64   1.22.2-8.el7                 base      942 k
 iptables                 x86_64   1.4.21-28.el7                base      433 k
 libmnl                   x86_64   1.0.3-7.el7                  base       23 k
 libnetfilter_conntrack   x86_64   1.0.6-1.el7_3                base       55 k
 libnfnetlink             x86_64   1.0.1-4.el7                  base       26 k
 perl                     x86_64   4:5.16.3-294.el7_6           updates   8.0 M
 perl-Carp                noarch   1.26-244.el7                 base       19 k
 perl-Encode              x86_64   2.51-7.el7                   base      1.5 M
 perl-Exporter            noarch   5.68-3.el7                   base       28 k
 perl-File-Path           noarch   2.09-2.el7                   base       26 k
 perl-File-Temp           noarch   0.23.01-3.el7                base       56 k
 perl-Filter              x86_64   1.49-3.el7                   base       76 k
 perl-Getopt-Long         noarch   2.40-3.el7                   base       56 k
 perl-HTTP-Tiny           noarch   0.033-3.el7                  base       38 k
 perl-PathTools           x86_64   3.40-5.el7                   base       82 k
 perl-Pod-Escapes         noarch   1:1.04-294.el7_6             updates    51 k
 perl-Pod-Perldoc         noarch   3.20-4.el7                   base       87 k
 perl-Pod-Simple          noarch   1:3.28-4.el7                 base      216 k
 perl-Pod-Usage           noarch   1.63-3.el7                   base       27 k
 perl-Scalar-List-Utils   x86_64   1.27-248.el7                 base       36 k
 perl-Socket              x86_64   2.010-4.el7                  base       49 k
 perl-Storable            x86_64   2.45-3.el7                   base       77 k
 perl-Text-ParseWords     noarch   3.29-4.el7                   base       14 k
 perl-Time-HiRes          x86_64   4:1.9725-3.el7               base       45 k
 perl-Time-Local          noarch   1.2300-2.el7                 base       24 k
 perl-constant            noarch   1.27-2.el7                   base       19 k
 perl-libs                x86_64   4:5.16.3-294.el7_6           updates   688 k
 perl-macros              x86_64   4:5.16.3-294.el7_6           updates    44 k
 perl-parent              noarch   1:0.225-244.el7              base       12 k
 perl-podlators           noarch   2.5.1-3.el7                  base      112 k
 perl-threads             x86_64   1.87-4.el7                   base       49 k
 perl-threads-shared      x86_64   1.43-6.el7                   base       39 k
 vim-common               x86_64   2:7.4.160-5.el7              base      5.9 M
 vim-filesystem           x86_64   2:7.4.160-5.el7              base       10 k
 which                    x86_64   2.20-7.el7                   base       41 k

Transaction Summary
================================================================================
Install  5 Packages (+36 Dependent packages)

Total download size: 21 M
Installed size: 68 M
Downloading packages:
--------------------------------------------------------------------------------
Total                                              3.8 MB/s |  21 MB  00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libnfnetlink-1.0.1-4.el7.x86_64                             1/41 
  Installing : libmnl-1.0.3-7.el7.x86_64                                   2/41 
  Installing : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                 3/41 
  Installing : iptables-1.4.21-28.el7.x86_64                               4/41 
  Installing : 2:vim-filesystem-7.4.160-5.el7.x86_64                       5/41 
  Installing : 2:vim-common-7.4.160-5.el7.x86_64                           6/41 
  Installing : gpm-libs-1.20.7-5.el7.x86_64                                7/41 
  Installing : groff-base-1.22.2-8.el7.x86_64                              8/41 
  Installing : 1:perl-parent-0.225-244.el7.noarch                          9/41 
  Installing : perl-HTTP-Tiny-0.033-3.el7.noarch                          10/41 
  Installing : perl-podlators-2.5.1-3.el7.noarch                          11/41 
  Installing : perl-Pod-Perldoc-3.20-4.el7.noarch                         12/41 
  Installing : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                   13/41 
  Installing : perl-Encode-2.51-7.el7.x86_64                              14/41 
  Installing : perl-Text-ParseWords-3.29-4.el7.noarch                     15/41 
  Installing : perl-Pod-Usage-1.63-3.el7.noarch                           16/41 
  Installing : 4:perl-libs-5.16.3-294.el7_6.x86_64                        17/41 
  Installing : 4:perl-macros-5.16.3-294.el7_6.x86_64                      18/41 
  Installing : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                      19/41 
  Installing : perl-Exporter-5.68-3.el7.noarch                            20/41 
  Installing : perl-constant-1.27-2.el7.noarch                            21/41 
  Installing : perl-Time-Local-1.2300-2.el7.noarch                        22/41 
  Installing : perl-Socket-2.010-4.el7.x86_64                             23/41 
  Installing : perl-Carp-1.26-244.el7.noarch                              24/41 
  Installing : perl-Storable-2.45-3.el7.x86_64                            25/41 
  Installing : perl-PathTools-3.40-5.el7.x86_64                           26/41 
  Installing : perl-Scalar-List-Utils-1.27-248.el7.x86_64                 27/41 
  Installing : 1:perl-Pod-Simple-3.28-4.el7.noarch                        28/41 
  Installing : perl-File-Temp-0.23.01-3.el7.noarch                        29/41 
  Installing : perl-File-Path-2.09-2.el7.noarch                           30/41 
  Installing : perl-threads-shared-1.43-6.el7.x86_64                      31/41 
  Installing : perl-threads-1.87-4.el7.x86_64                             32/41 
  Installing : perl-Filter-1.49-3.el7.x86_64                              33/41 
  Installing : perl-Getopt-Long-2.40-3.el7.noarch                         34/41 
  Installing : 4:perl-5.16.3-294.el7_6.x86_64                             35/41 
  Installing : which-2.20-7.el7.x86_64                                    36/41 
install-info: No such file or directory for /usr/share/info/which.info.gz
  Installing : 2:vim-enhanced-7.4.160-5.el7.x86_64                        37/41 
  Installing : iproute-4.11.0-14.el7_6.2.x86_64                           38/41 
  Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                  39/41 
  Installing : tree-1.6.0-10.el7.x86_64                                   40/41 
  Installing : lsof-4.87-6.el7.x86_64                                     41/41 
  Verifying  : perl-HTTP-Tiny-0.033-3.el7.noarch                           1/41 
  Verifying  : libmnl-1.0.3-7.el7.x86_64                                   2/41 
  Verifying  : iproute-4.11.0-14.el7_6.2.x86_64                            3/41 
  Verifying  : 2:vim-enhanced-7.4.160-5.el7.x86_64                         4/41 
  Verifying  : perl-threads-shared-1.43-6.el7.x86_64                       5/41 
  Verifying  : 4:perl-Time-HiRes-1.9725-3.el7.x86_64                       6/41 
  Verifying  : 1:perl-Pod-Escapes-1.04-294.el7_6.noarch                    7/41 
  Verifying  : lsof-4.87-6.el7.x86_64                                      8/41 
  Verifying  : perl-Exporter-5.68-3.el7.noarch                             9/41 
  Verifying  : perl-constant-1.27-2.el7.noarch                            10/41 
  Verifying  : perl-PathTools-3.40-5.el7.x86_64                           11/41 
  Verifying  : libnetfilter_conntrack-1.0.6-1.el7_3.x86_64                12/41 
  Verifying  : 1:perl-parent-0.225-244.el7.noarch                         13/41 
  Verifying  : which-2.20-7.el7.x86_64                                    14/41 
  Verifying  : 4:perl-libs-5.16.3-294.el7_6.x86_64                        15/41 
  Verifying  : groff-base-1.22.2-8.el7.x86_64                             16/41 
  Verifying  : perl-File-Temp-0.23.01-3.el7.noarch                        17/41 
  Verifying  : 1:perl-Pod-Simple-3.28-4.el7.noarch                        18/41 
  Verifying  : tree-1.6.0-10.el7.x86_64                                   19/41 
  Verifying  : perl-Time-Local-1.2300-2.el7.noarch                        20/41 
  Verifying  : gpm-libs-1.20.7-5.el7.x86_64                               21/41 
  Verifying  : 2:vim-common-7.4.160-5.el7.x86_64                          22/41 
  Verifying  : 4:perl-macros-5.16.3-294.el7_6.x86_64                      23/41 
  Verifying  : perl-Socket-2.010-4.el7.x86_64                             24/41 
  Verifying  : perl-Carp-1.26-244.el7.noarch                              25/41 
  Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                  26/41 
  Verifying  : perl-Storable-2.45-3.el7.x86_64                            27/41 
  Verifying  : perl-Scalar-List-Utils-1.27-248.el7.x86_64                 28/41 
  Verifying  : perl-Pod-Usage-1.63-3.el7.noarch                           29/41 
  Verifying  : iptables-1.4.21-28.el7.x86_64                              30/41 
  Verifying  : perl-Encode-2.51-7.el7.x86_64                              31/41 
  Verifying  : libnfnetlink-1.0.1-4.el7.x86_64                            32/41 
  Verifying  : perl-Pod-Perldoc-3.20-4.el7.noarch                         33/41 
  Verifying  : perl-podlators-2.5.1-3.el7.noarch                          34/41 
  Verifying  : perl-File-Path-2.09-2.el7.noarch                           35/41 
  Verifying  : perl-threads-1.87-4.el7.x86_64                             36/41 
  Verifying  : perl-Filter-1.49-3.el7.x86_64                              37/41 
  Verifying  : perl-Getopt-Long-2.40-3.el7.noarch                         38/41 
  Verifying  : perl-Text-ParseWords-3.29-4.el7.noarch                     39/41 
  Verifying  : 4:perl-5.16.3-294.el7_6.x86_64                             40/41 
  Verifying  : 2:vim-filesystem-7.4.160-5.el7.x86_64                      41/41 

Installed:
  iproute.x86_64 0:4.11.0-14.el7_6.2              lsof.x86_64 0:4.87-6.el7      
  net-tools.x86_64 0:2.0-0.24.20131004git.el7     tree.x86_64 0:1.6.0-10.el7    
  vim-enhanced.x86_64 2:7.4.160-5.el7            

Dependency Installed:
  gpm-libs.x86_64 0:1.20.7-5.el7                                                
  groff-base.x86_64 0:1.22.2-8.el7                                              
  iptables.x86_64 0:1.4.21-28.el7                                               
  libmnl.x86_64 0:1.0.3-7.el7                                                   
  libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3                                 
  libnfnetlink.x86_64 0:1.0.1-4.el7                                             
  perl.x86_64 4:5.16.3-294.el7_6                                                
  perl-Carp.noarch 0:1.26-244.el7                                               
  perl-Encode.x86_64 0:2.51-7.el7                                               
  perl-Exporter.noarch 0:5.68-3.el7                                             
  perl-File-Path.noarch 0:2.09-2.el7                                            
  perl-File-Temp.noarch 0:0.23.01-3.el7                                         
  perl-Filter.x86_64 0:1.49-3.el7                                               
  perl-Getopt-Long.noarch 0:2.40-3.el7                                          
  perl-HTTP-Tiny.noarch 0:0.033-3.el7                                           
  perl-PathTools.x86_64 0:3.40-5.el7                                            
  perl-Pod-Escapes.noarch 1:1.04-294.el7_6                                      
  perl-Pod-Perldoc.noarch 0:3.20-4.el7                                          
  perl-Pod-Simple.noarch 1:3.28-4.el7                                           
  perl-Pod-Usage.noarch 0:1.63-3.el7                                            
  perl-Scalar-List-Utils.x86_64 0:1.27-248.el7                                  
  perl-Socket.x86_64 0:2.010-4.el7                                              
  perl-Storable.x86_64 0:2.45-3.el7                                             
  perl-Text-ParseWords.noarch 0:3.29-4.el7                                      
  perl-Time-HiRes.x86_64 4:1.9725-3.el7                                         
  perl-Time-Local.noarch 0:1.2300-2.el7                                         
  perl-constant.noarch 0:1.27-2.el7                                             
  perl-libs.x86_64 4:5.16.3-294.el7_6                                           
  perl-macros.x86_64 4:5.16.3-294.el7_6                                         
  perl-parent.noarch 1:0.225-244.el7                                            
  perl-podlators.noarch 0:2.5.1-3.el7                                           
  perl-threads.x86_64 0:1.87-4.el7                                              
  perl-threads-shared.x86_64 0:1.43-6.el7                                       
  vim-common.x86_64 2:7.4.160-5.el7                                             
  vim-filesystem.x86_64 2:7.4.160-5.el7                                         
  which.x86_64 0:2.20-7.el7                                                     

Complete!
Removing intermediate container e465add73fb4
 ---> 5f7600975a99
Step 15/17 : RUN chmod u+x ${EXE_DIR}/*.sh && find ${EXE_DIR} -name "*.sh" | while read line;do bash -c ${line};done
 ---> Running in bc9dd63c0c32
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
 * base: ftp-srv2.kddilabs.jp
 * extras: ftp-srv2.kddilabs.jp
 * updates: ftp-srv2.kddilabs.jp
Resolving Dependencies
--> Running transaction check
---> Package dbus.x86_64 1:1.10.24-12.el7 will be updated
---> Package dbus.x86_64 1:1.10.24-13.el7_6 will be an update
---> Package dbus-libs.x86_64 1:1.10.24-12.el7 will be updated
---> Package dbus-libs.x86_64 1:1.10.24-13.el7_6 will be an update
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.3 will be updated
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.7 will be an update
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.3 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.7 will be an update
---> Package glibc.x86_64 0:2.17-260.el7_6.3 will be updated
---> Package glibc.x86_64 0:2.17-260.el7_6.4 will be an update
---> Package glibc-common.x86_64 0:2.17-260.el7_6.3 will be updated
---> Package glibc-common.x86_64 0:2.17-260.el7_6.4 will be an update
---> Package libblkid.x86_64 0:2.23.2-59.el7 will be updated
---> Package libblkid.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package libgcc.x86_64 0:4.8.5-36.el7 will be updated
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libmount.x86_64 0:2.23.2-59.el7 will be updated
---> Package libmount.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package libsmartcols.x86_64 0:2.23.2-59.el7 will be updated
---> Package libsmartcols.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package libssh2.x86_64 0:1.4.3-12.el7 will be updated
---> Package libssh2.x86_64 0:1.4.3-12.el7_6.2 will be an update
---> Package libstdc++.x86_64 0:4.8.5-36.el7 will be updated
---> Package libstdc++.x86_64 0:4.8.5-36.el7_6.2 will be an update
---> Package libuuid.x86_64 0:2.23.2-59.el7 will be updated
---> Package libuuid.x86_64 0:2.23.2-59.el7_6.1 will be an update
---> Package nss-pem.x86_64 0:1.0.3-5.el7 will be updated
---> Package nss-pem.x86_64 0:1.0.3-5.el7_6.1 will be an update
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7 will be updated
---> Package openssl-libs.x86_64 1:1.0.2k-16.el7_6.1 will be an update
---> Package python.x86_64 0:2.7.5-76.el7 will be updated
---> Package python.x86_64 0:2.7.5-77.el7_6 will be an update
---> Package python-libs.x86_64 0:2.7.5-76.el7 will be updated
---> Package python-libs.x86_64 0:2.7.5-77.el7_6 will be an update
---> Package shadow-utils.x86_64 2:4.1.5.1-25.el7 will be updated
---> Package shadow-utils.x86_64 2:4.1.5.1-25.el7_6.1 will be an update
---> Package systemd.x86_64 0:219-62.el7_6.5 will be updated
---> Package systemd.x86_64 0:219-62.el7_6.6 will be an update
---> Package systemd-libs.x86_64 0:219-62.el7_6.5 will be updated
---> Package systemd-libs.x86_64 0:219-62.el7_6.6 will be an update
---> Package tzdata.noarch 0:2018i-1.el7 will be updated
---> Package tzdata.noarch 0:2019a-1.el7 will be an update
---> Package util-linux.x86_64 0:2.23.2-59.el7 will be updated
---> Package util-linux.x86_64 0:2.23.2-59.el7_6.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch       Version                    Repository   Size
================================================================================
Updating:
 dbus                   x86_64     1:1.10.24-13.el7_6         updates     245 k
 dbus-libs              x86_64     1:1.10.24-13.el7_6         updates     169 k
 device-mapper          x86_64     7:1.02.149-10.el7_6.7      updates     293 k
 device-mapper-libs     x86_64     7:1.02.149-10.el7_6.7      updates     320 k
 glibc                  x86_64     2.17-260.el7_6.4           updates     3.7 M
 glibc-common           x86_64     2.17-260.el7_6.4           updates      12 M
 libblkid               x86_64     2.23.2-59.el7_6.1          updates     181 k
 libgcc                 x86_64     4.8.5-36.el7_6.2           updates     102 k
 libmount               x86_64     2.23.2-59.el7_6.1          updates     182 k
 libsmartcols           x86_64     2.23.2-59.el7_6.1          updates     140 k
 libssh2                x86_64     1.4.3-12.el7_6.2           updates     135 k
 libstdc++              x86_64     4.8.5-36.el7_6.2           updates     305 k
 libuuid                x86_64     2.23.2-59.el7_6.1          updates      82 k
 nss-pem                x86_64     1.0.3-5.el7_6.1            updates      74 k
 openssl-libs           x86_64     1:1.0.2k-16.el7_6.1        updates     1.2 M
 python                 x86_64     2.7.5-77.el7_6             updates      94 k
 python-libs            x86_64     2.7.5-77.el7_6             updates     5.6 M
 shadow-utils           x86_64     2:4.1.5.1-25.el7_6.1       updates     1.1 M
 systemd                x86_64     219-62.el7_6.6             updates     5.1 M
 systemd-libs           x86_64     219-62.el7_6.6             updates     407 k
 tzdata                 noarch     2019a-1.el7                updates     494 k
 util-linux             x86_64     2.23.2-59.el7_6.1          updates     2.0 M

Transaction Summary
================================================================================
Upgrade  22 Packages

Total download size: 33 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
--------------------------------------------------------------------------------
Total                                              4.8 MB/s |  33 MB  00:06     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libgcc-4.8.5-36.el7_6.2.x86_64                              1/44 
  Updating   : tzdata-2019a-1.el7.noarch                                   2/44 
  Updating   : glibc-common-2.17-260.el7_6.4.x86_64                        3/44 
  Updating   : glibc-2.17-260.el7_6.4.x86_64                               4/44 
  Updating   : systemd-libs-219-62.el7_6.6.x86_64                          5/44 
  Updating   : libuuid-2.23.2-59.el7_6.1.x86_64                            6/44 
  Updating   : libblkid-2.23.2-59.el7_6.1.x86_64                           7/44 
  Updating   : libmount-2.23.2-59.el7_6.1.x86_64                           8/44 
  Updating   : 2:shadow-utils-4.1.5.1-25.el7_6.1.x86_64                    9/44 
  Updating   : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64                    10/44 
  Updating   : python-libs-2.7.5-77.el7_6.x86_64                          11/44 
  Updating   : 1:dbus-libs-1.10.24-13.el7_6.x86_64                        12/44 
  Updating   : systemd-219-62.el7_6.6.x86_64                              13/44 
Failed to get D-Bus connection: Operation not permitted
  Updating   : 1:dbus-1.10.24-13.el7_6.x86_64                             14/44 
  Updating   : libsmartcols-2.23.2-59.el7_6.1.x86_64                      15/44 
  Updating   : util-linux-2.23.2-59.el7_6.1.x86_64                        16/44 
  Updating   : 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64            17/44 
  Updating   : 7:device-mapper-1.02.149-10.el7_6.7.x86_64                 18/44 
  Updating   : python-2.7.5-77.el7_6.x86_64                               19/44 
  Updating   : libssh2-1.4.3-12.el7_6.2.x86_64                            20/44 
  Updating   : nss-pem-1.0.3-5.el7_6.1.x86_64                             21/44 
  Updating   : libstdc++-4.8.5-36.el7_6.2.x86_64                          22/44 
  Cleanup    : 7:device-mapper-1.02.149-10.el7_6.3.x86_64                 23/44 
  Cleanup    : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64            24/44 
  Cleanup    : 1:dbus-1.10.24-12.el7.x86_64                               25/44 
  Cleanup    : systemd-219-62.el7_6.5.x86_64                              26/44 
  Cleanup    : util-linux-2.23.2-59.el7.x86_64                            27/44 
  Cleanup    : libmount-2.23.2-59.el7.x86_64                              28/44 
  Cleanup    : python-2.7.5-76.el7.x86_64                                 29/44 
  Cleanup    : python-libs-2.7.5-76.el7.x86_64                            30/44 
  Cleanup    : libblkid-2.23.2-59.el7.x86_64                              31/44 
  Cleanup    : 1:dbus-libs-1.10.24-12.el7.x86_64                          32/44 
  Cleanup    : systemd-libs-219-62.el7_6.5.x86_64                         33/44 
  Cleanup    : libssh2-1.4.3-12.el7.x86_64                                34/44 
  Cleanup    : libstdc++-4.8.5-36.el7.x86_64                              35/44 
  Cleanup    : 1:openssl-libs-1.0.2k-16.el7.x86_64                        36/44 
  Cleanup    : libuuid-2.23.2-59.el7.x86_64                               37/44 
  Cleanup    : libsmartcols-2.23.2-59.el7.x86_64                          38/44 
  Cleanup    : 2:shadow-utils-4.1.5.1-25.el7.x86_64                       39/44 
  Cleanup    : nss-pem-1.0.3-5.el7.x86_64                                 40/44 
  Cleanup    : glibc-common-2.17-260.el7_6.3.x86_64                       41/44 
  Cleanup    : glibc-2.17-260.el7_6.3.x86_64                              42/44 
  Cleanup    : tzdata-2018i-1.el7.noarch                                  43/44 
  Cleanup    : libgcc-4.8.5-36.el7.x86_64                                 44/44 
  Verifying  : nss-pem-1.0.3-5.el7_6.1.x86_64                              1/44 
  Verifying  : libblkid-2.23.2-59.el7_6.1.x86_64                           2/44 
  Verifying  : util-linux-2.23.2-59.el7_6.1.x86_64                         3/44 
  Verifying  : libmount-2.23.2-59.el7_6.1.x86_64                           4/44 
  Verifying  : python-libs-2.7.5-77.el7_6.x86_64                           5/44 
  Verifying  : libstdc++-4.8.5-36.el7_6.2.x86_64                           6/44 
  Verifying  : 2:shadow-utils-4.1.5.1-25.el7_6.1.x86_64                    7/44 
  Verifying  : libssh2-1.4.3-12.el7_6.2.x86_64                             8/44 
  Verifying  : libgcc-4.8.5-36.el7_6.2.x86_64                              9/44 
  Verifying  : tzdata-2019a-1.el7.noarch                                  10/44 
  Verifying  : 1:dbus-libs-1.10.24-13.el7_6.x86_64                        11/44 
  Verifying  : 7:device-mapper-libs-1.02.149-10.el7_6.7.x86_64            12/44 
  Verifying  : 1:openssl-libs-1.0.2k-16.el7_6.1.x86_64                    13/44 
  Verifying  : python-2.7.5-77.el7_6.x86_64                               14/44 
  Verifying  : libsmartcols-2.23.2-59.el7_6.1.x86_64                      15/44 
  Verifying  : 1:dbus-1.10.24-13.el7_6.x86_64                             16/44 
  Verifying  : libuuid-2.23.2-59.el7_6.1.x86_64                           17/44 
  Verifying  : glibc-common-2.17-260.el7_6.4.x86_64                       18/44 
  Verifying  : glibc-2.17-260.el7_6.4.x86_64                              19/44 
  Verifying  : systemd-libs-219-62.el7_6.6.x86_64                         20/44 
  Verifying  : systemd-219-62.el7_6.6.x86_64                              21/44 
  Verifying  : 7:device-mapper-1.02.149-10.el7_6.7.x86_64                 22/44 
  Verifying  : python-2.7.5-76.el7.x86_64                                 23/44 
  Verifying  : libblkid-2.23.2-59.el7.x86_64                              24/44 
  Verifying  : 1:dbus-1.10.24-12.el7.x86_64                               25/44 
  Verifying  : libgcc-4.8.5-36.el7.x86_64                                 26/44 
  Verifying  : libstdc++-4.8.5-36.el7.x86_64                              27/44 
  Verifying  : 1:openssl-libs-1.0.2k-16.el7.x86_64                        28/44 
  Verifying  : glibc-2.17-260.el7_6.3.x86_64                              29/44 
  Verifying  : 7:device-mapper-libs-1.02.149-10.el7_6.3.x86_64            30/44 
  Verifying  : libuuid-2.23.2-59.el7.x86_64                               31/44 
  Verifying  : nss-pem-1.0.3-5.el7.x86_64                                 32/44 
  Verifying  : libssh2-1.4.3-12.el7.x86_64                                33/44 
  Verifying  : systemd-libs-219-62.el7_6.5.x86_64                         34/44 
  Verifying  : 1:dbus-libs-1.10.24-12.el7.x86_64                          35/44 
  Verifying  : systemd-219-62.el7_6.5.x86_64                              36/44 
  Verifying  : 2:shadow-utils-4.1.5.1-25.el7.x86_64                       37/44 
  Verifying  : libmount-2.23.2-59.el7.x86_64                              38/44 
  Verifying  : util-linux-2.23.2-59.el7.x86_64                            39/44 
  Verifying  : libsmartcols-2.23.2-59.el7.x86_64                          40/44 
  Verifying  : python-libs-2.7.5-76.el7.x86_64                            41/44 
  Verifying  : tzdata-2018i-1.el7.noarch                                  42/44 
  Verifying  : glibc-common-2.17-260.el7_6.3.x86_64                       43/44 
  Verifying  : 7:device-mapper-1.02.149-10.el7_6.3.x86_64                 44/44 

Updated:
  dbus.x86_64 1:1.10.24-13.el7_6                                                
  dbus-libs.x86_64 1:1.10.24-13.el7_6                                           
  device-mapper.x86_64 7:1.02.149-10.el7_6.7                                    
  device-mapper-libs.x86_64 7:1.02.149-10.el7_6.7                               
  glibc.x86_64 0:2.17-260.el7_6.4                                               
  glibc-common.x86_64 0:2.17-260.el7_6.4                                        
  libblkid.x86_64 0:2.23.2-59.el7_6.1                                           
  libgcc.x86_64 0:4.8.5-36.el7_6.2                                              
  libmount.x86_64 0:2.23.2-59.el7_6.1                                           
  libsmartcols.x86_64 0:2.23.2-59.el7_6.1                                       
  libssh2.x86_64 0:1.4.3-12.el7_6.2                                             
  libstdc++.x86_64 0:4.8.5-36.el7_6.2                                           
  libuuid.x86_64 0:2.23.2-59.el7_6.1                                            
  nss-pem.x86_64 0:1.0.3-5.el7_6.1                                              
  openssl-libs.x86_64 1:1.0.2k-16.el7_6.1                                       
  python.x86_64 0:2.7.5-77.el7_6                                                
  python-libs.x86_64 0:2.7.5-77.el7_6                                           
  shadow-utils.x86_64 2:4.1.5.1-25.el7_6.1                                      
  systemd.x86_64 0:219-62.el7_6.6                                               
  systemd-libs.x86_64 0:219-62.el7_6.6                                          
  tzdata.noarch 0:2019a-1.el7                                                   
  util-linux.x86_64 0:2.23.2-59.el7_6.1                                         

Complete!
Loaded plugins: fastestmirror, ovl
Cleaning repos: base extras updates
Cleaning up list of fastest mirrors
Removing intermediate container bc9dd63c0c32
 ---> 1f439da4ac76
Step 16/17 : EXPOSE 80
 ---> Running in b4b0eba2f76a
Removing intermediate container b4b0eba2f76a
 ---> fc3b54baa6b6
Step 17/17 : CMD ["/sbin/init"]
 ---> Running in 0f8f69bc2d8f
Removing intermediate container 0f8f69bc2d8f
 ---> 0cebeaa888c4
Successfully built 0cebeaa888c4
Successfully tagged apache/httpd:latest

_________________________________________________________________________________

-->apache/httpd was built

Build completed in 117 seconds.


[oracle@centos tmp]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
apache/httpd        latest              0cebeaa888c4        3 minutes ago       503MB

[oracle@centos tmp]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
aaf4852dabab        apache/httpd        "/sbin/init"        4 minutes ago       Up 3 minutes        0.0.0.0:8080->80/tcp   test1

Docker imagesの確認

コード表示

[oracle@centos tmp]$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
apache/httpd        latest              0cebeaa888c4        34 minutes ago      503MB

起動コンテナの確認

コード表示

[oracle@centos tmp]$ docker stop $(docker ps -qa) && docker rm $(docker ps -qa)
5edf42a78b62
5edf42a78b62
[oracle@centos tmp]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

コンテナ起動

コード表示

[oracle@centos tmp]$ docker run -p 8080:80 --privileged -it --name test1 -d apache/httpd
055aaa91b9a15429d38b546302a2ffb1032bb8cb5609d753d49fef437c5227e8
[oracle@centos tmp]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                  NAMES
055aaa91b9a1        apache/httpd        "/sbin/init"        5 seconds ago       Up 4 seconds        0.0.0.0:8080->80/tcp   test1

コンテナ中に潜る

コード表示

[oracle@centos tmp]$ docker exec -it test1 /bin/bash
[root@f6f256dd2e99 /]# whoami
root

ここからが結構楽しい

apacheでぐぐる

コード表示

[root@f6f256dd2e99 /]# find . -name *apache* 2>/dev/null
./sys/fs/selinux/booleans/awstats_purge_apache_log_files
./usr/share/vim/vim74/syntax/apachestyle.vim
./usr/share/vim/vim74/syntax/apache.vim
./usr/share/httpd/noindex/images/apache_pb.gif
./usr/share/httpd/icons/apache_pb.png
./usr/share/httpd/icons/apache_pb2.png
./usr/share/httpd/icons/apache_pb.svg
./usr/share/httpd/icons/apache_pb2.gif
./usr/share/httpd/icons/apache_pb.gif
./usr/sbin/apachectl

ここらへんのやつひろう

コード表示

[root@f6f256dd2e99 /]# find . -name *httpd* 2>/dev/null | grep -E "conf|log|bin|service"
./sys/fs/selinux/booleans/httpd_mod_auth_ntlm_winbind
./usr/lib/systemd/system/httpd.service
./usr/lib/tmpfiles.d/httpd.conf
./usr/sbin/httpd
./var/log/httpd
./etc/logrotate.d/httpd
./etc/sysconfig/httpd
./etc/httpd/conf/httpd.conf

プロセス確認する。httpdプロセス起動させた。

コード表示

[root@f6f256dd2e99 /]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  51288  3340 ?        Ss   12:51   0:00 /sbin/init
root        17  0.0  0.0  39084  5964 ?        Ss   12:51   0:00 /usr/lib/systemd/systemd-journald
root        29  0.0  0.0  35320  2076 ?        Ss   12:51   0:00 /usr/lib/systemd/systemd-udevd
dbus       806  0.0  0.0  58104  2104 ?        Ss   12:51   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       910  0.0  0.0  24252  1560 ?        Ss   12:51   0:00 /usr/lib/systemd/systemd-logind
root      2713  0.0  0.0  11820  1892 pts/1    Ss   12:51   0:00 /bin/bash
root      3119  1.0  0.0  90264  1896 tty1     Ss+  13:04   0:00 /bin/login --                     
root      3150  0.0  0.0  51740  1740 pts/1    R+   13:05   0:00 ps aux
[root@f6f256dd2e99 /]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
[root@f6f256dd2e99 /]# systemctl start httpd.service
[root@f6f256dd2e99 /]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-04-29 13:08:15 UTC; 2s ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 3297 (httpd)
   Status: "Processing requests..."
   CGroup: /docker/f6f256dd2e9999869e12e18a2eee82a56a3260fb69d5fa6aa6f6760575f438b2/system.slice/httpd.service
           ├─3297 /usr/sbin/httpd -DFOREGROUND
           ├─3298 /usr/sbin/httpd -DFOREGROUND
           ├─3299 /usr/sbin/httpd -DFOREGROUND
           ├─3300 /usr/sbin/httpd -DFOREGROUND
           ├─3301 /usr/sbin/httpd -DFOREGROUND
           └─3302 /usr/sbin/httpd -DFOREGROUND
           ‣ 3297 /usr/sbin/httpd -DFOREGROUND

Apr 29 13:08:15 f6f256dd2e99 systemd[1]: Starting The Apache HTTP Server...
Apr 29 13:08:15 f6f256dd2e99 httpd[3297]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Apr 29 13:08:15 f6f256dd2e99 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@f6f256dd2e99 /]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  51376  3448 ?        Ss   12:51   0:00 /sbin/init
root        17  0.0  0.0  39084  5992 ?        Ss   12:51   0:00 /usr/lib/systemd/systemd-journald
root        29  0.0  0.0  35320  2076 ?        Ss   12:51   0:00 /usr/lib/systemd/systemd-udevd
dbus       806  0.0  0.0  58104  2104 ?        Ss   12:51   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       910  0.0  0.0  24252  1560 ?        Ss   12:51   0:00 /usr/lib/systemd/systemd-logind
root      2713  0.0  0.0  11820  1892 pts/1    Ss   12:51   0:00 /bin/bash
root      3297  0.0  0.0 224052  4984 ?        Ss   13:08   0:00 /usr/sbin/httpd -DFOREGROUND
apache    3298  0.0  0.0 224052  2952 ?        S    13:08   0:00 /usr/sbin/httpd -DFOREGROUND
apache    3299  0.0  0.0 224052  2952 ?        S    13:08   0:00 /usr/sbin/httpd -DFOREGROUND
apache    3300  0.0  0.0 224052  2952 ?        S    13:08   0:00 /usr/sbin/httpd -DFOREGROUND
apache    3301  0.0  0.0 224052  2952 ?        S    13:08   0:00 /usr/sbin/httpd -DFOREGROUND
apache    3302  0.0  0.0 224052  2952 ?        S    13:08   0:00 /usr/sbin/httpd -DFOREGROUND
root      3313  0.8  0.0  90264  1984 tty1     Ss+  13:08   0:00 /bin/login --  
root      3352  0.0  0.0  51740  1748 pts/1    R+   13:09   0:00 ps aux

apachectlとかつかえそう

コード表示

[root@055aaa91b9a1 /]# apachectl -h
Usage: /usr/sbin/httpd [-D name] [-d directory] [-f file]
                       [-C "directive"] [-c "directive"]
                       [-k start|restart|graceful|graceful-stop|stop]
                       [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
  -D name            : define a name for use in  directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed vhost settings
  -t -D DUMP_RUN_CFG : show parsed run settings
  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  -T                 : start without DocumentRoot(s) check
  -X                 : debug mode (only one worker, do not detach)
[root@055aaa91b9a1 /]# apachectl -v
Server version: Apache/2.4.6 (CentOS)
Server built:   Nov  5 2018 01:47:09
[root@055aaa91b9a1 /]# apachectl -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@055aaa91b9a1 /]# apachectl -T
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
httpd (pid 2733) already running
[root@055aaa91b9a1 /]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0  43180  3440 ?        Ss   13:14   0:00 /sbin/init
root        19  0.0  0.0  39084  5996 ?        Ss   13:14   0:00 /usr/lib/systemd/systemd-journald
root        30  0.0  0.0  35604  2364 ?        Ss   13:14   0:00 /usr/lib/systemd/systemd-udevd
dbus       617  0.0  0.0  58104  2104 ?        Ss   13:14   0:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root       711  0.0  0.0  24252  1536 ?        Ss   13:14   0:00 /usr/lib/systemd/systemd-logind
root      2713  0.0  0.0  11820  1896 pts/1    Ss   13:15   0:00 /bin/bash
root      2733  0.0  0.0 224052  4980 ?        Ss   13:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache    2734  0.0  0.0 224052  2948 ?        S    13:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache    2735  0.0  0.0 224052  2948 ?        S    13:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache    2736  0.0  0.0 224052  2948 ?        S    13:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache    2737  0.0  0.0 224052  2948 ?        S    13:15   0:00 /usr/sbin/httpd -DFOREGROUND
apache    2738  0.0  0.0 224052  2948 ?        S    13:15   0:00 /usr/sbin/httpd -DFOREGROUND
root      2794  0.0  0.0  21704   788 tty1     Rs+  13:21   0:00 /bin/login --       
root      2795  0.0  0.0  51740  1752 pts/1    R+   13:21   0:00 ps aux

サーバー名とかポート番号とか確認してみる

コード表示

[root@055aaa91b9a1 /]# cat /etc/httpd/conf/httpd.conf | grep -A 20 "Name"
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other 
#  blocks below.
#

    AllowOverride none
    Require all denied


#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your

Listen確認

コード表示

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the 
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf

#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
[root@055aaa91b9a1 /]# cat /etc/httpd/conf/httpd.conf | grep -A 10 "ServerRoot"
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the 
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
[root@055aaa91b9a1 /]# cat /etc/httpd/conf/httpd.conf | grep -A 10 "log"
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so 'log/access_log'
# with ServerRoot set to '/www' will be interpreted by the
# server as '/www/log/access_log', where as '/log/access_log' will be
# interpreted as '/log/access_log'.

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on the
# Mutex directive, if file-based mutexes are used.  If you wish to share the
# same ServerRoot for multiple httpd daemons, you will need to change at
# least PidFile.
#
ServerRoot "/etc/httpd"

#
--
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a 
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a 
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error_log"

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn


    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a 
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per- access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    #CustomLog "logs/access_log" common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    CustomLog "logs/access_log" combined



    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar


動作確認

うてばいい

コード表示

http://192.168.1.109:8080とかアドレスバーに入力してEnter。

ログとか見る

コード表示

[root@055aaa91b9a1 /]# cd /etc/httpd
[root@055aaa91b9a1 httpd]# ls -lt
total 12
drwxr-xr-x. 2 root root 4096 Apr 29 12:31 conf
drwxr-xr-x. 2 root root 4096 Apr 29 12:31 conf.d
drwxr-xr-x. 2 root root 4096 Apr 29 12:31 conf.modules.d
lrwxrwxrwx. 1 root root   19 Apr 29 12:31 logs -> ../../var/log/httpd
lrwxrwxrwx. 1 root root   29 Apr 29 12:31 modules -> ../../usr/lib64/httpd/modules
lrwxrwxrwx. 1 root root   10 Apr 29 12:31 run -> /run/httpd
[root@055aaa91b9a1 httpd]# vi logs
[root@055aaa91b9a1 httpd]# cd logs
[root@055aaa91b9a1 logs]# pwd
/etc/httpd/logs
[root@055aaa91b9a1 logs]# ls
access_log  error_log

[root@055aaa91b9a1 logs]# vi access_log
192.168.1.109 - - [29/Apr/2019:13:30:07 +0000] "GET / HTTP/1.1" 200 125 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [29/Apr/2019:13:30:07 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "http://192.168.1.109:8080/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [29/Apr/2019:13:30:59 +0000] "-" 408 - "-" "-"

[root@055aaa91b9a1 logs]# vi error_log
[Mon Apr 29 13:15:37.766768 2019] [suexec:notice] [pid 2733] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
[Mon Apr 29 13:15:37.772196 2019] [auth_digest:notice] [pid 2733] AH01757: generating secret for digest authentication ...
[Mon Apr 29 13:15:37.772682 2019] [lbmethod_heartbeat:notice] [pid 2733] AH02282: No slotmem from mod_heartmonitor
[Mon Apr 29 13:15:37.774138 2019] [mpm_prefork:notice] [pid 2733] AH00163: Apache/2.4.6 (CentOS) configured -- resuming normal operations
[Mon Apr 29 13:15:37.774150 2019] [core:notice] [pid 2733] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

curlアタックスクリプト

コード表示

[oracle@centos tmp]$ ll
合計 16
-rw-r--r--. 1 oracle docker 254  4月 29 21:30 Dockerfile
-rwxr--r--. 1 oracle docker 197  4月 29 22:48 atk.sh
-rw-r--r--. 1 oracle docker 125  4月 29 20:20 index.html
-rwxr--r--. 1 oracle docker 570  4月 29 21:06 kick.sh
[oracle@centos tmp]$ cat atk.sh
#!/bin/bash
 
cnt=0
trap 'echo '';echo "try count:${cnt}";exit 1;' INT                                                       
 
while :
do
  curl -o /dev/null $1
  cnt=$((${cnt}+1))
  sleep 1
done

アタックしつつtail -fでログ監査

terminal2つ開いて

コード表示

--one session
[oracle@centos tmp]$ ./atk.sh http://192.168.1.109:8080
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0  70343      0 --:--:-- --:--:-- --:--:--  122k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0   105k      0 --:--:-- --:--:-- --:--:--  122k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0  22253      0 --:--:-- --:--:-- --:--:-- 25000
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0   101k      0 --:--:-- --:--:-- --:--:--  122k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0   105k      0 --:--:-- --:--:-- --:--:--  122k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0   107k      0 --:--:-- --:--:-- --:--:--  122k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0   131k      0 --:--:-- --:--:-- --:--:--  122k
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   125  100   125    0     0   112k      0 --:--:-- --:--:-- --:--:--  122k
^C
try count:8
--another session
[root@055aaa91b9a1 logs]# tail -f access_log
192.168.1.109 - - [29/Apr/2019:13:30:07 +0000] "GET / HTTP/1.1" 200 125 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [29/Apr/2019:13:30:07 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "http://192.168.1.109:8080/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
192.168.1.109 - - [29/Apr/2019:13:30:59 +0000] "-" 408 - "-" "-"
192.168.1.109 - - [29/Apr/2019:13:49:35 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:36 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:37 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:38 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:39 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:40 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:41 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"
192.168.1.109 - - [29/Apr/2019:13:49:42 +0000] "GET / HTTP/1.1" 200 125 "-" "curl/7.29.0"

Docker便利

awkでログ題材にしてたから、つくったってログファイル生成したかったのが本音でした。