Creating and using the Apache container via Docker

Source: Internet
Author: User
Tags docker run

Objective: To create an Apache-hosted image and launch 5 Apache containers from within a Linux external service

1. Installing Apache

Docker run-t-I--name=qxy_apache centosyuminstall  httpdexit

2. Make image

Docker commit Qxy_apache Qxy_apache:v1. 0 [email protected]-1 ~]# Docker imagesrepository          TAG                 IMAGE ID            CREATED             VIRTUAL sizeqxy_apache          v1. 0                9b6f8b6054b5         seconds ago      196.6 MB

3. Create a container

Docker run--name=apache_8001-d-t-i-P8001: the-v/root/httpd/httpd_8001:/var/www/HTML Qxy_apachedocker Run--name=apache_8002-d-t-i-P8002: the-v/root/httpd/httpd_8002:/var/www/HTML Qxy_apachedocker Run--name=apache_8003-d-t-i-P8003: the-v/root/httpd/httpd_8003:/var/www/HTML Qxy_apachedocker Run--name=apache_8004-d-t-i-P8004: the-v/root/httpd/httpd_8004:/var/www/HTML Qxy_apachedocker Run--name=apache_8005-d-t-i-P8005: the-v/root/httpd/httpd_8005:/var/www/html Qxy_apache
#这里-D is run in the background to facilitate batch execution; Note that if only the-D container fails to start

4, make the simplest page ^_^

[[Email protected]1 httpd]# cd/root/httpd[[email protected]-1 for in  Do Echo "  "$i >/$i/index.htmldone[[email protected]-1 Find Xargs Cat Hello Httpd_8001hello httpd_8002hello httpd_8003hello httpd_8004hello httpd_8005

5. Start httpd

[[email protected] httpd]# for i in ' SEQ 1 5 '
> Do
> Docker exec apache_800$i httpd-k start

> Done

6. Test Apache

[[Email protected]2 for in 'seq15'do > Curl http://192.168.110.111:800$idoneHello Httpd_8001hello Httpd_8002hello Httpd_8003hello Httpd_8004hello httpd_8005

Creating and using the Apache container via Docker

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.