Das Folgende ist mein docker-compose.yml
version: "3.7" services: php: build: context: . volumes: - ".:/app" - "~/.ssh:/root/.ssh" #- '$SSH_AUTH_SOCK:/ssh-agent' environment: SSH_AUTH_SOCK: "/ssh-agent" APP_NAME: "Docker Laravel" APP_ENV: "test" APP_KEY: "" APP_DEBUG: "true" APP_URL: "/" APP_TIMEZONE: "UTC" DB_ECLIPSE_HOST: "db" DB_ECLIPSE_PORT: "3306" DB_ECLIPSE_DATABASE: "app_menu" DB_ECLIPSE_USERNAME: "homestead" DB_ECLIPSE_PASSWORD: "homestead" expose: - 9000 depends_on: - db nginx: build: context: "./docker/nginx" ports: - "80:80" environment: NGINX_PHP_UPSTREAM: php # Start URI with /template/... NGINX_URI_PREFIX: / volumes: - "./var/log/nginx:/var/log/nginx" depends_on: - php db: build: context: ./docker/mysql ports: - "3306:3306" volumes: - db_volume:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: "homestead" MYSQL_ECLIPSE_HOST: db MYSQL_ECLIPSE_DATABASE: "app_menu" MYSQL_ECLIPSE_USER: "homestead" MYSQL_ECLIPSE_PASSWORD: "homestead" MYSQL_AUTH_COMMAND: --default-authentication-plugin=mysql_native_password elk: image: "willdurand/elk" ports: - "900:85" volumes: - "./docker/logstash:/etc/logstash" - "./docker/logstash/patterns:/opt/logstash/patterns" - "./var/log/laravel:/var/log/laravel" - "./var/log/nginx:/var/log/nginx" volumes: db_volume:
Das Folgende ist meine Docker-Datei
FROM php:7.3-fpm RUN apt-get update RUN apt-get install -y libzip-dev git procps unzip RUN docker-php-ext-install -j$(nproc) zip RUN pecl install xdebug-3.0.4 && docker-php-ext-enable xdebug RUN curl -o /tmp/security_checker -L "https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64" && mv /tmp/security_checker /usr/bin/local-php-security-checker && chmod +x /usr/bin/local-php-security-checker # Install composer from docker repo COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable pdo_mysql WORKDIR /app ADD docker/php/php.ini $PHP_INI_DIR/conf.d/ ADD docker/php/xdebug.ini $PHP_INI_DIR/conf.d/ EXPOSE 9000 # Likely don't need to force this to the foreground. If it fails add `-F` option CMD ["php-fpm"]PHP-Version: 7.3 Laravel 8
您必须配置您的 nginx。 Nginx默认路由是/etc/nginx/html/。 所以你需要一条像这样的路线。