Docker-compose up 未运行

Docker-compose up 未运行

使用 docker-compose 运行 docker 容器时遇到奇怪的问题。这是一个带有 apache+php 的 docker 容器

如果我手动运行它-一切都正常。

[root@opcis proxy-handler]# docker run -itd -v proxy_html:/var/www/html -p 9001:80 --name=webapp-handler2 jaels/proxy-handler
0b217e295e345056308daedaea441d2b123dd05c7cf29d5c219939f557f8374b
[root@opcis proxy-handler]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                  NAMES
0b217e295e34        jaels/proxy-handler   "/bin/sh -c '/usr/sbi"   6 seconds ago       Up 1 seconds        0.0.0.0:9001->80/tcp   webapp-handler2

但是如果我用 docker-compose 运行它 - 它会失败并显示“httpd (pid 8) 正在运行”

[root@opcis proxy-handler]# cat docker-compose.yml 
version: "2"
services:
        proxy-handler:
                image: jaels/proxy-handler 
                ports:
                        - 9001:80
                volumes:
                        - ./webdata:/var/www/html

[root@opcis proxy-handler]# docker-compose up
Creating proxyhandler_proxy-handler_1
Attaching to proxyhandler_proxy-handler_1
proxy-handler_1  | Passing arguments to httpd using apachectl is no longer supported.
proxy-handler_1  | You can only start/stop/restart httpd using this script.
proxy-handler_1  | If you want to pass extra arguments to httpd, edit the
proxy-handler_1  | /etc/sysconfig/httpd config file.
proxy-handler_1  | httpd (pid 8) already running
proxyhandler_proxy-handler_1 exited with code 0

[root@opcis proxy-handler]# docker-compose ps
            Name                          Command               State    Ports
------------------------------------------------------------------------------
proxyhandler_proxy-handler_1   /bin/sh -c /usr/sbin/apach ...   Exit 0        

答案1

请参阅 Dockerfile 和 run-apache.sh 脚本这个存储库简而言之,如果 httpd 进程认为它已经在运行,那么它就不会再次启动。在 Dockerfile 中添加一个删除该 pid 文件的启动脚本,即可启动 httpd。

相关内容