gpt4 book ai didi

docker - Dockerfile无效

转载 作者:行者123 更新时间:2023-12-02 20:55:48 25 4
gpt4 key购买 nike

我从Docker开始遇到了一个问题。我想在一个Apache容器中启用mod_rewrite并正在使用此docker-compose.yml

version: '3'
services:
php-apache:
image: php:7.2.1-apache
ports:
- 80:80
volumes:
- ./DocumentRoot:/var/www/html:z
这个Dockerfile:
FROM php:7.2.1-apache
RUN a2enmod rewrite
RUN service apache2 restart
我运行“docker build --no-cache”。输出:
Sending build context to Docker daemon  90.16MB
Step 1/3 : FROM php:7.2.1-apache
---> f99d319c7004
Step 2/3 : RUN a2enmod rewrite
---> Running in 883573f39a39
Enabling module rewrite.
To activate the new configuration, you need to run:
service apache2 restart
Removing intermediate container 883573f39a39
---> 18c40ce865a6
Step 3/3 : RUN service apache2 restart
---> Running in b79bab530dc7
Restarting Apache httpd web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message
.
Removing intermediate container b79bab530dc7
---> 8e2cfa7094f7
Successfully built 8e2cfa7094f7
结果:未安装mod_rewrite。当我登录到控制台并手动运行“a2enmod rewrite”时,一切正常。我在这里想念什么?

最佳答案

docker build --no-cache .创建docker镜像<none>:<none>
您的撰写文件引用了基本image: php:7.2.1-apache。基本上,您正在准备不使用的图像。
您可能需要使用-t参数来标记要构建的图像,然后在撰写文件中引用该图像。例如:

docker build -t my-awesome-php-with-a2enmod --no-cache .
version: '3'
services:
php-apache:
image: my-awesome-php-with-a2enmod
ports:
- 80:80
volumes:
- ./DocumentRoot:/var/www/html:z

关于docker - Dockerfile无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63105389/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com