有过两种方式解决 docker stop nginx 1>/dev/null 2>&1 | exit 0 docker rm -f nginx 1>/dev/null 2>&1 | exit 0 docker restart 测试后可正常删除