gpt4 book ai didi

bash - "/bin/sh: 1: [“apache2ctl” , : not found"in docker

转载 作者:行者123 更新时间:2023-12-02 19:08:32 25 4
gpt4 key购买 nike

我有一个简单的 Dockerfile

FROM ubuntu
RUN apt-get update
RUN apt-get install -y apache2
RUN apt-get install -y apache2-utils
RUN apt-get clean
RUN apt-get upgrade -y
EXPOSE 80
CMD [“apache2ctl”, “-D FOREGROUND”]

我用下面的语句构建它

docker build -t mywebserver .

效果很好,但是当我想执行它时

docker run -p 80:80 mywebserver

它返回您可以在标题中看到的错误消息。我还尝试了 /usr/sbin/apache2ctl 而不是 apache2ctl 以确保它不是因为在 PATH 中丢失但没有帮助。

非常感谢您的帮助。

最佳答案

改变这一行

CMD [“apache2ctl”, “-D FOREGROUND”]

CMD ["apache2ctl", "-D","FOREGROUND"]

你应该对你的RUN进行分组,顺便说一下,看

https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/

关于bash - "/bin/sh: 1: [“apache2ctl” , : not found"in docker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45082745/

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