You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Docker构建PHP开发环境报错:Dockerfile不存在的解决方法

解决Dockerfile不存在的错误:Windows10+Laragon Nginx+Docker Desktop环境

问题原因

你的docker-compose.yml中app服务的build配置指定了错误的构建上下文:

  • context: ./public 会让Docker到public目录下查找Dockerfile
  • 但实际Dockerfile位于项目根目录(Minos文件夹下),因此Docker找不到该文件,触发"failed to read dockerfile: no such file or directory"错误。

解决方案

修改docker-compose.yml中app服务的build配置,将构建上下文改为项目根目录:

version: "3.8"
services:
  app:
    container_name: 'minos-php'
    restart: always
    build:
      context: .  # 修改为根目录作为构建上下文
      dockerfile: Dockerfile
    ports:
      - "8008:80"
    volumes:
      - ./public:/var/www/html/
      - .:/var/www
    depends_on:
      - mysql
    links:
      - mysql
  mysql:
    container_name: 'minos-mysql'
    image: arm64v8/mysql:oracle
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    volumes:
      - mysql-data:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "33060:3306"
volumes:
  mysql-data:

验证操作

  1. 保存修改后的docker-compose.yml
  2. 回到项目根目录(Minos文件夹),重新执行构建命令:
docker compose up -d --build

此时Docker会在根目录找到Dockerfile,正常完成环境构建。

内容的提问来源于stack exchange,提问作者user20217774

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 12:40:50