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