Docker容器已停止但页面仍可访问,无法停止本地运行容器
Troubleshooting Your Docker Container Issues
Hey there! Let's work through these two Docker problems you're facing—they're pretty common, so we'll get them sorted out.
1. Container is stopped, but the website still loads in the browser
This almost always boils down to one of two things:
- Browser caching: Your browser might have stored a local copy of the page. Try a hard refresh with
Ctrl+Shift+R(Windows/Linux) orCmd+Shift+R(macOS), or open an incognito/private window to load the page again. If it doesn't show up there, the cache was the culprit. - Another service using port 80: It's possible another process on your machine is listening on port 80. To check:
- On Windows: Run
netstat -ano | findstr ":80"in Command Prompt/PowerShell to find the process ID (PID) using the port, then match it in Task Manager. - On Linux/macOS: Run
lsof -i :80ornetstat -tulpn | grep :80to identify the process using port 80.
- On Windows: Run
2. Can't stop the container
Let's go through steps to forcefully stop/remove the unresponsive container:
- First, get your container ID/name from the output of
docker ps -a(you already know this works, so grab that identifier). - Try a forceful stop: Run
docker stop -t 0 <container-id-or-name>—the-t 0skips the graceful shutdown period and terminates the container immediately. - If stopping fails, force delete the container: Use
docker rm -f <container-id-or-name>—this command will kill the container process and remove it in one go. - Restart the Docker daemon: If the above steps don't work, the Docker service might be in a stuck state.
- Windows: Open Task Manager, find "Docker Desktop" in the Processes tab, right-click and select "Restart".
- Linux: Run
sudo systemctl restart docker. - macOS: Open Docker Desktop, click the menu bar icon, select "Restart".
- Kill residual host processes (last resort): If the container is still hanging, check for leftover processes on your host machine. Run
ps aux | grep <your-container-image-name>to find related PIDs, then terminate them withkill -9 <pid>. After that, you should be able to clean up the container withdocker rm -f <container-id-or-name>.
内容的提问来源于stack exchange,提问作者Neer Patel
相关产品推荐
相关产品推荐

