san*_*ndy 3 docker dockerfile docker-compose alpine-linux
Apache 未在 alpine docker 映像中启动。这是我的 docker 文件
FROM alpine:latest
RUN apk update
RUN apk upgrade
RUN apk add bash
RUN apk add apache2
RUN apk add openrc
RUN rc-update add apache2
EXPOSE 80 443
WORKDIR /var/www/localhost/htdocs
COPY index.html /var/www/localhost/htdocs
Run Code Online (Sandbox Code Playgroud)
我尝试在登录正在运行的 docker 后手动启动 Apache 但没有工作
错误是
* You are attempting to run an openrc service on a
* system which openrc did not boot.
* You may be inside a chroot or you may have used
* another initialization system to boot this system.
* In this situation, you will get unpredictable results!
* If you really want to do this, issue the following command:
* touch /run/openrc/softlevel
* ERROR: networking failed to start
* ERROR: cannot start apache2 as networking would not start
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,您可以在不使用 openrc 的情况下启动 apache。
添加RUN mkdir -p /run/apache2到您的 Dockerfile,apache 将 httpd.pid 文件存储在此目录中。最后使用以下命令启动 apache:exec /usr/sbin/httpd -D FOREGROUND
尝试这个 :
FROM alpine:latest
RUN \
apk add --no-cache \
apache2-proxy \
apache2-ssl \
apache2-utils \
curl \
git \
logrotate \
openssl
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
WORKDIR /var/www/localhost/htdocs
COPY index.html /var/www/localhost/htdocs
EXPOSE 80
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7370 次 |
| 最近记录: |