使用docker工具箱(windows)时,docker-compose volume mount为空

时间:2018-02-09 01:38:18

标签: php laravel apache docker docker-compose

我正在尝试使用docker-compose将我的laraver 5.5应用程序停靠。

这是我的 docker-compose.yml 文件定义:

version: '2.1'
services:

  # The Database
  database:
    image: mysql:5.7
    restart: always
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
      timeout: 20s
      retries: 10
    environment:
      - "MYSQL_DATABASE=myapp"
      - "MYSQL_USER=myapp"
      - "MYSQL_PASSWORD=123456"
      - "MYSQL_ROOT_PASSWORD=secret"
    ports:
        - "33061:3306"

  # The Application
  app:
    depends_on:
      database:
        condition: service_healthy
    build:
      context: ./
      dockerfile: ./docker-compose/app.dockerfile
    volumes:
      - ./:/var/www/html
    environment:
      - "DB_CONNECTION=mysql"
      - "DB_HOST=database"
      - "DB_PORT=3306"
      - "DB_DATABASE=myapp"
      - "DB_USERNAME=myapp"
      - "DB_PASSWORD=123456"
    ports:
      - "8080:80"

这是我的 ./ docker-compose / app.dockerfile

# Base image
FROM php:7.1-apache

# Configure system
RUN apt-get update && apt-get install -y \
        libmcrypt-dev \
        mysql-client \
        zlib1g-dev \
        --no-install-recommends \
        && apt-get clean \
        && rm -rf /var/lib/apt/lists/* \
        && docker-php-ext-install mcrypt pdo_mysql

# Add php.ini and apache2.conf
COPY docker-compose/php.ini $PHP_INI_DIR/php.ini
COPY docker-compose/apache2.conf /etc/apache2/apache2.conf

#  Configuring Apache
RUN rm -rf /etc/apache2/sites-available/* \
    && rm -rf /etc/apache2/sites-enabled/*

# Enable rewrite module
RUN a2enmod rewrite

# Download and install composer globally
RUN curl -s http://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer

# Add vendor binaries to PATH
ENV PATH=/var/www/html/vendor/bin:$PATH

我使用以下命令启动我的堆栈:

docker-compose -d --build通过我的Windows 10上的Docker Quickstart Terminal

一切都很好并且运行(我通过docker-compose ps检查)。当我访问应用程序URL时,我从apache收到禁止的错误,所以我决定使用docker exec -it my_app_1 /bin/bash命令登录到容器,然后我进入/var/www/html目录并注意到它是空的。

在Windows中卷安装是否有效?

0 个答案:

没有答案