Docker in depth 1-try running a simple web environment

Source: Internet
Author: User

Docker in depth 1-try running a simple web environment

Purpose: Add a Web environment on the base image (PCNK/BASE:V2): Sync

Practice: Start a new container, and then incrementally add the Web service, and then submit to the image, where port mappings are used, and data volumes are mounted.

First, the "Pcnk/base:v2" on the base image run a container "Web" to install sync httpd and other services required 1) container "Web" [[email protected]  base]$ docker run -d -v /home/download:/home/download -v /home/datacenter:/ data --name web -p 10032:22 pcnk/base:v2    152d0ca20346fc4a0d0a5a8fe04671910dcc685801f572159ae3c7f5dd2ecf43[[email protected] base]$  docker ps -lcontainer id        image                COMMAND                 CREATED              STATUS               PORTS                    names152d0ca20346        pcnk/base:v2         "/usr/bin/supervisor   7 seconds ago       up  6 seconds        0.0.0.0:10032->22/tcp    web   [[email protected] base]$ ssh -p 10032 [email  Protected][email protected] ' s password: last login: wed may  6  10:11:26 2015 from 172.17.42.12) Adjust the time: [[email protected] /]# mv -f /etc /localtime /etc/localtime.old[[email protected] /]# ln -s /usr/share/zoneinfo/ asia/shanghai /etc/localtime[[email protected] /]# echo  ' ZONE= "Asia/Shanghai"   >/etc/sysconfig/clock[[email protected] /]# cd /home/download/vriteam-sync-0.2.4[[email  protected] vriteam-sync-0.2.4]# yum -y install wget gcc perl autoconf automake  make bzip2 tar zip && yum clean all[[email protected]  VRITEAM-SYNC-0.2.4]#&NBSP;./INSTALL&NBSP;ALL3) Install the PHP module: [[email protected] vriteam-sync-0.2.4]# . /install ssh2[[email protected] vriteam-sync-0.2.4]# ./install svn[[email  Protected] vriteam-sync-0.2.4]# cd /etc/php.d[[email protected] php.d]# cat  ssh2.ini svn.ini ; Enable ssh2 extension moduleextension=ssh2.so;  enable svn extension moduleextension=svn.so[[email protected] vriteam-sync-0.2.4]#  ls /lib64/php/modules/curl.so  fileinfo.so  json.so  mysqli.so   mysql.so  pdo_mysql.so  pdo.so  pdo_sqlite.so  phar.so   sqlite3.so  ssh2.so  svn.so  zip.so[[email protected] conf.d]# yum clean  ALL4) Adjust the configuration of the httpd: [[Email protected] supervisor.d]# ln -s /data/supervisor.d/httpd.ini  . [[email protected] supervisor.d]# lltotal 4lrwxrwxrwx. 1 root root 28  may  6 02:46 httpd.ini -> /data/supervisor.d/httpd.ini-rw-rw-r--.   1 root root 41 may  5 10:47 sshd.ini[[email protected]  Supervisor.d]# cd /etc/httpd/conf.d/[[email protected] conf.d]# mv welcome.conf  /tmp/[[email protected] conf.d]# ln -s /data/httpd/conf.d/sync.conf . [[Email protected] conf.d]# lltotal 16-rw-r--r--.  1 root root 2893  mar 12 15:07 autoindex.conf-rw-r--r--.  1 root root  691 oct  31  2014 php.Conf-rw-r--r--.  1 root root  366 mar 12 15:08 readmelrwxrwxrwx.  1 root root   28 May  6 02:47 sync.conf ->  /data/httpd/conf.d/sync.conf-rw-r--r--.  1 root root 1252 mar 12 14:57  userdir.conf[[email protected] conf.d]# cat sync.conf <virtualhost *:80 >    ServerAdmin [email protected]    ServerName  Sync.ec.office    documentroot /data/sync/src    directoryindex  index.html index.php       <Directory /data/sync/src>         AllowOverride None         Require all granted    </Directory>     Errorlog /data/log/sync-error_log    customlog /data/log/sync-access_log common</virtualhost> Second, Submitted as Image: "Pcnk/web:sync" [[email protected] base]$ docker commit 152d0ca20346  Pcnk/web:sync three, on the basis of image "Pcnk/web:sync", create a new container "App_sync", map 80 ports, start httpd service 1) container "App_sync" [[Email  protected] base]$ docker run -d -v /home/download:/home/download -v  /home/datacenter:/data --name app_sync -p 10042:22 -p 80:80 pcnk/web: sync[[email protected] base]$ ssh -p 10042 [email protected]the  authenticity of host  ' [127.0.0.1]:10042  ([127.0.0.1]:10042) '  can ' t be  Established. rsa key fingerprint is 15:18:db:44:ed:03:ca:ac:15:a3:d0:ea:ac:01:7e:27.are you  sure you want to continue connecting  (yes/no)?  yeswarning: permanently  added ' [127.0.0.1]:10042 '   (RSA)  to the list of known hosts. [email protected] ' s password: last login: wed may  6 11:51:55  2015 from 172.17.42.1[[email protected] ~]# ps -efUID         PID  PPID  C STIME TTY           time cmdroot         1      0  0 12:02 ?         00:00:00 /usr/bin/python /usr/bin/supervisordroot          9     1  0 12:02 ?         00:00:00 /usr/sbin/httpd -DFOREGROUNDroot         10     1  0 12:02 ?        00:00:00 /usr/sbin/sshd -dapache       12     9  0 12:02 ?         00:00:00 /usr/sbin/httpd -DFOREGROUNDapache       13     9  0 12:02 ?         00:00:00 /usr/sbin/httpd -DFOREGROUNDapache       14     9  0 12:02 ?         00:00:00 /usr/sbin/httpd -DFOREGROUNDapache      15      9  0 12:02 ?         00:00:00 /usr/sbin/httpd -dforegroundapache      16      9  0 12:02 ?         00:00:00 /usr/sbin/httpd -DFOREGROUNDroot         17    10  0 12:03 ?         00:00:00 sshd: [email protected]/0root         19    17  0 12:03 pts/0     00:00:00 -bashroot        36    &NBSP;19&NBSP;&NBSP;0&NBSP;12:03&NBSP;PTS/0&NBSP;&NBSP;&NBSP;&NBSP;00:00:00&NBSP;PS&NBSP;-EF2) control of the httpd service [[ email protected] ~]# supervisorctl status httpd httpd                              RUNNING   pid 9, uptime 0:00:48        [[email protected] ~]# chmod 777 /data/sync/src/tmp/[[email protected] ~]#  chmod 777 /data/sync/src/data/[[email protected] ~]# chmod 777 /data/ sync/src/install/[[email protected] ~]# chmod 777 /data/sync/src/db.cfg.php  3) through the Web Access, boot installation, DB this link skipped. Four, stop the use of container, delete the image "Pcnk/web:sync", submitted to a new image "Website/sync", and then through this to start the service 1) image "Website/sync" [[Email  protected] base]$ docker stop app_sync[[email protected] base]$  docker rm app_sync[[email protected] base]$ dcoker rmi [[email  protected] base]$ docker imagesrepository           TAG                  IMAGE ID            CREATED              VIRTUAL SIZEwebsite/sync         latest               1bda5d872bf7        22 minutes ago       508 MBpcnk/web             sync                 b41b76b51e1a        4 hours ago          505.9 MBpcnk/base            v2                   064aa35dfcef        6 hours ago          251.3 mbcentos              7                     fd44297e2ddb        2 weeks ago          215.7 MBcentos               centos7              fd44297e2ddb        2 weeks ago          215.7 MBcentos               latest               fd44297e2ddb        2 weeks ago         &nBsp;215.7 mb[[email protected] base]$ docker rmi b41b76b51e1auntagged: pcnk /web:sync[[email protected] base]$ docker commit -m  "Add  httpd,php  service, For sync this app. " -a " Pcnk " ea8daf7b62d4 website/sync2) container" App_sync_web "[[email protected]  base]$ docker run -d -v /home/download:/home/download -v /home/ datacenter:/data --name app_sync_web -p 40022:22 -p 80:80 website/sync[[ email protected] base]$ docker ps -lcontainer id         IMAGE                  COMMAND                 CREATED             STATUS               ports                                         NAMES2ab2a9866251         website/sync:latest    "/usr/bin/supervisor    6 seconds ago       Up 4 seconds         0.0.0.0:80->80/tcp, 0.0.0.0:40022->22/tcp   app_ sync_web    v. Now let's take a look at the association between images [[email protected] ~]$ docker images - -treewarning:  '--tree '  is deprecated, it will be removed soon.  See usage.└─6941bfcbbfca virtual size: 0 b  └─41459f052977 virtual  size: 215.7 mb&Nbsp;   └─fd44297e2ddb virtual size: 215.7 mb tags: centos: Centos7, centos:latest, centos:7      └─751a85a0d00b virtual  size: 215.7 mb        └─19b009f08542 virtual  Size: 228.1 MB          └─420cb9e73c70  virtual size: 251.3 mb             └─e97f94a79de0 virtual size: 251.3 mb               └─fde06c761bde Virtual Size: 251.3 MB                 └─dbfae1099999  virtual size: 251.3 mb                   └─064aa35dfcef virtual size: 251.3 mb tags: pcnk/base:v2                     └─b41b76b51e1a  virtual size: 505.9 mb                       └─1bda5d872bf7 virtual size: 508  mb tags: website/sync:latest


Docker in depth 1-try running a simple web environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.