イメージの取得

インタラクティブ実行

core@localhost ~ $ docker run -i -t -h centos centos:centos6 /bin/bash
bash-4.1# cat /etc/redhat-release
CentOS release 6.5 (Final)
bash-4.1# exit
exit

Apache をインストールしてデーモンとして実行する

  1. CentOS6.5(Guest) に httpd をインストールする
    core@localhost ~ $ docker run -i -t -h centos centos:centos6 /bin/bash
    bash-4.1# yum -y install httpd
    bash-4.1# ls /etc/init.d/
    functions  halt  htcacheclean  httpd  iptables	killall  netconsole  netfs  network  rdisc  restorecond  sandbox  single  udev-post
    bash-4.1# exit
    exit
  2. Image を commit する
    core@localhost ~ $ docker ps -a
    CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
    abb0ba529ee9        centos:centos6      /bin/bash           5 minutes ago       Exited (0) About a minute ago                       high_pare
    core@localhost ~ $ docker commit abb0ba529ee9 cent6_apache
    633e8b36e0837adccc606fda644f9067e7cd1dbd66ee24d14eb491d8738ad1cd
  3. 仮想 CeontOS6 上で Apache を foreground プロセスとして起動する
    core@localhost ~ $ docker run -p 8080:80 -d cent6_apache /usr/sbin/apachectl -DFOREGROUND
    47b822b0fe8a81810f7cd977ca79bab7f8ffeaff9bd8aac632e06b181d98388b
    core@localhost ~ $ docker ps
    CONTAINER ID        IMAGE                 COMMAND                CREATED             STATUS              PORTS                  NAMES
    47b822b0fe8a        cent6_apache:latest   /usr/sbin/apachectl    6 seconds ago       Up 5 seconds        0.0.0.0:8080->80/tcp   insane_lovelace
    docker run -d で動かすプロセスは、foreground である必要がある。/etc/initd/httpd のように、apache を起動して exit 0 で終了するプログラムを指定した場合、docker container はすぐに終了してしまう
    apache.png

Docker


添付ファイル: fileapache.png 2295件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2014-12-13 (土) 23:37:38 (3419d)
Short-URL: http://hondou.homedns.org/pukiwiki/index.php?cmd=s&k=aa9d6a847e
ISBN10
ISBN13
9784061426061