httpd安装编排
最近写了一个纯html的网页想让别人也看到那就要部署一下,所以今天介绍一下啊httpd部署html静态页面的过程
1.创建目录 mkdir web-html
2.编写docker-compose.yml文件
docker-compose.yml
version: '3'
services:
web:
container_name: web-httpd
image: httpd
ports:
- "8080:80"
privileged: true
restart: always #重启docker时,自动启动相关容器
volumes:
- "./resume/:/usr/local/apache2/htdocs/"
实操命令
[root@localhost software]# mkdir web-html # 创建目录
[root@localhost software]# ll
total 0
drwxr-xr-x. 2 root root 24 May 7 00:01 web-html
[root@localhost software]# cd web-html/
[root@localhost web-html]# ll
total 1560
-rw-r--r--. 1 root root 1596144 May 7 00:01 resume.zip # 上传html资源
[root@localhost web-html]# unzip resume.zip #解压
[root@localhost web-html]# ll
total 1560
drwxr-xr-x. 3 root root 38 May 7 00:02 resume
-rw-r--r--. 1 root root 1596144 May 7 00:01 resume.zip
[root@localhost web-html]# cd resume/
[root@localhost resume]# ll
total 24
drwxr-xr-x. 6 root root 54 Apr 28 16:57 assets
-rw-r--r--. 1 root root 21282 Apr 28 16:37 index.html
[root@localhost resume]# cd ..
[root@localhost web-html]# vim docker-compose.yml
[root@localhost web-html]# ll
total 1564
-rw-r--r--. 1 root root 222 May 7 00:05 docker-compose.yml
drwxr-xr-x. 3 root root 38 May 7 00:02 resume
-rw-r--r--. 1 root root 1596144 May 7 00:01 resume.zip
[root@localhost web-html]# docker-compose up -d
内容扩展
例如现我们改动docker-compose.yml里volumes: 的配置参数,改动后配置如下
volumes: - “./web/:/usr/local/apache2/htdocs/”
在docker-compose.yml文件的同级目录下创建文件结构如下:
├─web
│ ├─web01-html
│ │ │index.html
│ ├─web02-html
│ │ │index.html
│ ├─web03-html
│ │ │index.html
扩展实操
[root@localhost web-html]# ll
total 1564
-rw-r--r--. 1 root root 222 May 7 00:05 docker-compose.yml
drwxr-xr-x. 2 root root 24 May 7 00:01 web
[root@localhost web-html]# cd web
[root@localhost web]# ll
drwxr-xr-x. 2 root root 24 May 7 00:10 web01-html
drwxr-xr-x. 2 root root 24 May 7 00:10 web02-html
drwxr-xr-x. 2 root root 24 May 7 00:11 web03-html
[root@localhost web-html]# cd web01-html # 其它web02-html、web02-html文件也是如此
[root@localhost web01-html]# ll
-rw-r--r--. 1 root root 21282 Apr 28 16:37 index.html
这样的目录结构,web01-html、web02-html、web03-html 都是一个单独的html的web项目
访问 :web01-html :http://ip:8080/web01-html
访问 :web02-html :http://ip:8080/web02-html
访问 :web03-html :http://ip:8080/web03-html
最后
至此便是使用Docker-compose 安装编排httpd的过程,希望能给您带去帮助!!!