Docker container deployment Apache static Web site

Source: Internet
Author: User
Tags docker ps docker run

Deploying static Web sites in containers
1. Understand container port mappings first
(1). Set Port mappings for containers
Run [-P] [-p]
-P,--publish-all=true | False defaults to False (maps all exposed ports of the container)
Docker Run-p-i-t Centos/bin/bash

-P,--publish=[] (specifies the port of the container)
Containerport (Specify port for container only)
Docker run-p 80-i-T Centos/bin/bash
Hostport:containerport (both host port and container port are specified, and the corresponding relationship is the same)
Docker run-p 8080:80-i-T Centos/bin/bash
Ip::containerport (Specify port for IP and container)
Docker run-p 0.0.0.0:80-i-T Centos/bin/bash
Ip:hostPort:containerPort (IP host port and container port are specified)
Docker run-p 0.0.0.0:8080:80-i-T Centos/bin/bash

2. Implementation steps,
(1). Create an interactive container that maps 80 ports
[email protected] ~]# Docker run-p--name web123-i-T Centos:6.6/bin/bash

(2). Installing Nginx
[email protected]/]# Yum install httpd-y

(3). Install text editor vim (easy to edit text)
[email protected]/]# Yum install vim-y

(4). Create a static page
Create a static file under the/var/www/html/directory


(5). Modifying the Apache configuration file
Modify the Default Web site profile path to/var/www/html by default without modifying it
[Email protected] ~]# vim/etc/httpd/conf/httpd.conf

(6). Run Apache
[[email protected] ~]#/etc/init.d/httpd start

(7). Verifying website Access
Use: Docker PS (view mapped ports)
[[email protected] ~]# Docker PS

You can also use the Docker Port web123 command to view the port mapping situation

Use Docker top web123 to see how the container is running
[email protected] ~]# Docker top web123

Via browser Http://IP: Port authentication

Docker container deployment Apache static Web site

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.