编程语言
首页 > 编程语言> > Docker-如何在docker-compose.yml中设置Apache PHP

Docker-如何在docker-compose.yml中设置Apache PHP

作者:互联网

我用它来为PHP设置nginx:

nginx:
    image: nginx:latest
    ports:
        - 8080:80
    volumes:
        - ./code:/code
        - ./site.conf:/etc/nginx/conf.d/site.conf
    links:
        - php
php:
    image: php:7-fpm
    volumes:
        - ./code:/code

但是Apache呢?如何在docker-compose.yml中设置Apache PHP?

在此guide之后:

version: '2'

services:
  php:
    build: php
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./php/www:/var/www/html

错误:

ERROR: In file './docker-compose.yml' service 'version' doesn't have any configuration options. All top level keys in your docker-compose.yml must map to a dictionary of configuration options.

有任何想法吗?我正在使用Xubuntu 16.04.

编辑:

在设法将docker-compose升级到1.9之后,我尝试使用以下文件:

version: '2'
services:
    php:
        build: php
        expose:
            - 9000
        volumes:
            - ./php/www:/var/www/html

    apache2:
        image: webdevops/apache:latest
        args:
            - PHP_SOCKET=php:9000
        volumes:
            - ./php/www:/var/www/html
        ports:
            - 80:80
            - 443:443
        links:
            - php

错误:

$sudo docker-compose up -d
Building php
ERROR: Cannot locate specified Dockerfile: Dockerfile

Docker真是太痛苦了!

任何想法如何解决这一问题?

解决方法:

我将选择webdevops dockerized apache,因为它具有简单的配置:

version: '2'
services:
    php:
        build: php
        expose:
            - 9000
        volumes:
            - ./php/www:/var/www/html

    apache2:
        image: webdevops/apache:latest
        args:
            - PHP_SOCKET=php:9000
        volumes:
            - ./php/www:/var/www/html
        ports:
            - 80:80
            - 443:443
        links:
            - php

标签:docker,docker-compose,apache,ubuntu-16-04,php
来源: https://codeday.me/bug/20191026/1936132.html