[root@localhost ~]# mkdir /data/{aaa,bbb,ccc} -p
[root@localhost ~]# docker run -itd -p 80:80 -v /data/aaa/:/dct/aaa -v /data/bbb/:/dct/bbb -v /data/ccc/:/dct/ccc nginx:latest
[root@localhost ~]# echo " aaa test1 " >> /data/aaa/index.html
[root@localhost ~]# echo " bbb test1 " >> /data/bbb/index.html
[root@localhost ~]# echo " ccc test1 " >> /data/ccc/index.html
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fa6f920f875c nginx:latest "nginx -g 'daemon of…" 3 hours ago Up 30 minutes 0.0.0.0:80->80/tcp serene_buck
[root@localhost ~]#
First of all: I think that after entering the docker container inside, modify nginx configuration file. However, the container was found nginx docker by direct mounting, which is considerably simplified, not many common commands (e.g., vi, yum, etc.).
then:
docker cp: a data copy between the container and the host.
[the root @ localhost ~] # Docker CP fa6f920f875c : /etc/nginx/conf.d/default.conf (copy data container to the current position of the host).
[root@localhost ~]# ls
anaconda-ks.cfg default.conf
[root@localhost ~]#
[root@localhost ~]# cat default.conf
server {
listen 80;
server_name aaa.test.cn;
location / {
root /dct/aaa;
index index.html index.htm;
}
}
server {
listen 80;
server_name bbb.test.cn;
location / {
root /dct/bbb;
index index.html index.htm;
}
}
server {
listen 80;
server_name ccc.test.cn;
location / {
root /dct/ccc;
index index.html index.htm;
}
}
[root@localhost ~]#
[the root @ localhost ~] # Docker CP default.conf fa6f920f875c: /etc/nginx/conf.d/ (the copy of the current data to the container)
[the root @ localhost ~] # Docker fa6f920f875c the restart restarting the container, the configuration.
Configuration / etc / hosts, resolve to achieve IP and domain name
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.0.1 aaa.test.cn
172.16.0.1 bbb.test.cn
172.16.0.1 ccc.test.cn
[root@localhost ~]#
Description: IP address is the IP address of the network card eth0 export.
[root@localhost ~]# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.0.1 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::d887:12ff:fedf:29e prefixlen 64 scopeid 0x20<link>
ether da:87:12:df:02:9e txqueuelen 1000 (Ethernet)
RX packets 1178165 bytes 386644124 (368.7 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 423412 bytes 34334996 (32.7 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]#
verification:
[root@localhost ~]# curl aaa.test.cn
aaa test1
[root@localhost ~]# curl bbb.test.cn
bbb test1
[root@localhost ~]# curl ccc.test.cn
CCC test1
[root@localhost ~]#
Thus it has been implemented to achieve a multi-domain access nginx with 80 ports by docker way.
Coupled with pfsense following configuration to achieve LAN access (LAN: 192.168.168.X / 24) by way of web pages
As well as the most important step:
Modify the hosts file in windows. Domain names and IP to achieve resolution (C: \ WINDOWS \ system32 \ drivers \ etc)
Note: hosts file in the bottom line space.
Last verification: