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

Angular项目通过dockerode管理Docker容器时查看容器报404错误求助

Troubleshooting the 404 Error When Fetching Docker Container Info in Angular

Hey there, let's walk through the most likely reasons you're hitting that 404 error when clicking your button to fetch Docker container details:

  • You're targeting the wrong server port
    Angular runs on localhost:4200 by default, but the Docker API doesn't live there. The Docker daemon uses a Unix socket (/var/run/docker.sock on Linux/macOS) by default, or if you've enabled TCP access, it typically uses port 2375 (unencrypted) or 2376 (encrypted). Your request is hitting the Angular dev server instead of the Docker API, hence the 404.

  • Missing proxy configuration for CORS and routing
    Even if you point to the correct Docker API port directly, you'll run into CORS issues. The fix here is setting up an Angular proxy to forward requests from your dev server to the Docker API. Create a proxy.conf.json file in your project root:

    {
      "/containers": {
        "target": "http://localhost:2375",
        "secure": false,
        "changeOrigin": true
      }
    }
    

    Then start your Angular app with ng serve --proxy-config proxy.conf.json. This will route requests like http://localhost:4200/containers/... to the Docker API at http://localhost:2375/containers/....

  • The container no longer exists
    Double-check if the container ID 97bfae66b11f is valid. Run docker ps -a in your terminal to list all containers (running or stopped). If this ID doesn't show up, the container was probably deleted, which would cause a 404 when trying to fetch its details.

  • Docker API isn't accessible or configured properly

    • On Linux/macOS: Make sure your user is in the docker group (run sudo usermod -aG docker $USER and log out/in) to access the Unix socket. If using TCP, confirm the Docker daemon is configured to listen on the correct port.
    • On Windows (Docker Desktop): Go to Settings > Docker Engine and ensure you've enabled "Expose daemon on tcp://localhost:2375 without TLS" (note: this is unsafe for production, but fine for local development).
  • Typos in your request path
    Double-check your Angular service code to make sure you're using the correct container ID and path. A missing slash, extra character, or misspelled container ID could easily lead to a 404.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.19 08:36:56