安装Apache

DockerHub官方提供的Apache镜像,并不带PHP环境。如果需要PHP环境支持,可以选择PHP镜像(https://registry.hub.docker.com/_/php/),并请使用含-apache标签的镜像,如7.0.7-apache。如果仅需要使用Apache运行静态HTML文件,则使用默认官方镜像即可。

1. 创建工作目录

$ mkdir ~/apache-alpine

2. 创建项目

创建项目目录public-html,并在此目录下创建index.html:

$ mkdir ~/apache-alpine/public-html

$ vim ~/apache-alpine/public-html/index.html

index.html中的内容如下:

<! DOCTYPE html>
<html>
    <body>
        <p>Hello, Docker! </p>
    </body>
</html>

3.编辑Dockerfile

4. 创建镜像

5. 创建apache容器

Last updated

Was this helpful?