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

Docker Compose启动报错:./entrypoint.sh未找到但文件存在

Alright, let's dig into this "entrypoint not found" issue you're hitting. I've seen this pop up a few times with Windows + Docker setups, so let's break down the likely causes and fixes:

1. Check the script filename vs your entrypoint command

You mentioned seeing entrypoint.sh listed when running ls, but the error says ./entrypoint: not found—that's a red flag. Double-check your docker-compose.yml to make sure your entrypoint directive points to the correct filename:

# ❌ Wrong (if your file is named entrypoint.sh)
entrypoint: ./entrypoint
# ✅ Correct
entrypoint: ./entrypoint.sh
2. Fix line ending mismatches (Windows CRLF vs Linux LF)

Windows uses CRLF line endings by default, but Linux-based containers expect LF. If you created entrypoint.sh on Windows, the hidden carriage returns can break the shell's ability to interpret the script—even though the file exists.

Quick fixes:

  • Use a text editor like VS Code: Open the file, click the "CRLF" indicator in the bottom-right corner, switch to "LF", then save.
  • If using Git, configure it to not convert line endings for this repo:
    git config core.autocrlf false
    
  • If you're building a custom image, add a line to your Dockerfile to clean up line endings:
    RUN sed -i 's/\r$//' entrypoint.sh
    
3. Make sure the script has execute permissions

Even if the file exists, the container's shell won't run it without execute permissions.

How to fix:

  • If you're on Windows, use Git Bash or WSL to run this command on your local file:
    chmod +x entrypoint.sh
    
  • If you're mounting the script via a volume, you can adjust your docker-compose entrypoint to set permissions first:
    entrypoint: ["sh", "-c", "chmod +x ./entrypoint.sh && ./entrypoint.sh"]
    
4. Confirm the container's working directory

Ensure the container's working directory matches where your entrypoint.sh is located. If you're mounting a local folder to a specific path in the container (like /app), either:

  • Use the full path to the script in your entrypoint: /app/entrypoint.sh
  • Add a working_dir directive to your docker-compose service:
    services:
      mssql:
        # ... other config ...
        working_dir: /app
        entrypoint: ./entrypoint.sh
    
Quick debug test

To narrow down the issue, modify your entrypoint to run debug commands first:

entrypoint: ["sh", "-c", "ls -l && cat entrypoint.sh && ./entrypoint.sh"]

This will show you the file permissions, the exact content of the script (including any hidden line endings), and then attempt to run it—this should help you spot exactly what's going wrong.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 06:54:23