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

Docker-Compose启动前端服务报错:OCI运行时创建失败求助

Fixing "exec: "PORT=8000": executable file not found" in Docker Compose

Hey there, let's get this Docker Compose issue sorted out quickly. The error you're seeing is telling you exactly what's wrong—Docker is trying to run PORT=8000 as if it's an executable program, which it isn't. This almost always happens when you mix up how you set environment variables and define your container's start command.

Here are the two most common scenarios and how to fix them:

1. Wrong command/entrypoint in docker-compose.yml

If your docker-compose.yml has something like this:

services:
  frontend:
    # ... other config
    command: PORT=8000 npm start

Docker treats the entire string as a single command to execute, so it looks for an executable named PORT=8000 (which doesn't exist). Instead, separate the environment variable from the start command using the environment field:

services:
  frontend:
    # ... other config
    environment:
      - PORT=8000
    command: npm start

Alternatively, if you're using a .env file, you can reference it with env_file: .env instead of listing variables directly.

2. Misconfigured CMD/ENTRYPOINT in your Dockerfile

If your Dockerfile uses the array format for CMD incorrectly, like this:

CMD ["PORT=8000", "npm", "start"]

The array format runs commands directly (without a shell), so it tries to execute PORT=8000 as the main command. Fix this in one of two ways:

Option A: Use shell format for CMD

Let the shell handle the environment variable assignment:

CMD PORT=8000 npm start

Option B: Set the environment variable with ENV first

Define the variable separately, then run your command:

ENV PORT=8000
CMD ["npm", "start"]

The key takeaway here is that environment variable assignments need to be handled either via Docker's environment configuration (in compose or Dockerfile) or passed through a shell that can parse them—don't treat the assignment itself as an executable command.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 09:33:33