使用Docker轻松搭建Apache

创建设置文件

version: '3.3'

services:
  httpd:
    image: httpd:2.4
    ports:
      - '80:80'
    volumes:
      - ./htdocs:/usr/local/apache2/htdocs
      - ./conf:/usr/local/apache2/conf
<html>
<body>
<h1>Test Container</h1>
</body>
</html>

将 httpd.conf 文件从容器复制到 Windows 上,以便进行操作。

docker run --rm --name httpd -d httpd:2.4
docker cp httpd:/usr/local/apache2/conf/ conf
docker rm -f httpd

目录结构

C:.
│  docker-compose.yml
│
├─conf
│  │  httpd.conf
│  │  magic
│  │  mime.types
│  │
│  ├─extra
│
└─htdocs
        index.html

执行

docker-compose up
广告
将在 10 秒后关闭
bannerAds