[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eCloud Code for VS Code simplifies debugging applications deployed to Cloud Run using \u003ccode\u003eskaffold debug\u003c/code\u003e, eliminating the need for manual setup like port forwarding.\u003c/p\u003e\n"],["\u003cp\u003eDebugging requires a Cloud Code-ready Cloud Run application with \u003ccode\u003eskaffold.yaml\u003c/code\u003e and a \u003ccode\u003elaunch.json\u003c/code\u003e file of type \u003ccode\u003ecloudcode.cloudrun\u003c/code\u003e, which you can further customize.\u003c/p\u003e\n"],["\u003cp\u003eThe debugging process can be initiated via the VS Code command palette using the \u003cstrong\u003eDebug on Cloud Run Emulator\u003c/strong\u003e command, offering various configuration options like builder type, service settings, and environment variables.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code automatically handles language-specific debugger configurations for Node.js, Python, Go, Java, and .NET, ensuring seamless debugging experiences.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting container-building issues, such as the \u003ccode\u003eBUILD_DOCKER_UNKNOWN\u003c/code\u003e error, can often be resolved by restarting Docker or managing disk space using tools like Docker's Disk Usage extension.\u003c/p\u003e\n"]]],[],null,["# Debug a Cloud Run service in Cloud Code for VS Code\n\nCloud Code for VS Code lets you easily debug an application deployed to\nCloud Run by leveraging\n[`skaffold debug`](https://skaffold.dev/docs/workflows/debug). For detailed\ninformation about Skaffold debugging, see\n[Debugging with Skaffold](https://skaffold.dev/docs/workflows/debug/).\n\nYou don't need to complete manual setup like setting up port forwarding or\ninjecting language-specific debug arguments. Debugging requires a\nCloud Code-ready Cloud Run application\nthat includes a `skaffold.yaml` configuration file and a `launch.json` file of\ntype `cloudcode.cloudrun`.\n\nDebug your Cloud Run service\n----------------------------\n\nTo debug your service, follow these steps:\n\n1. To run your service and attach a debugger session to it, open the\n command palette (press `Ctrl`/`Cmd`+`Shift`+`P` or click **View** \\\u003e\n **Command Palette** )\n and then run the **Debug on Cloud Run Emulator** command.\n\n2. In the Run/Debug on Cloud Run Emulator dialog, set the\n specifications for your configuration:\n\n - Choose Docker or Buildpacks as your builder and then specify your Dockerfile or Buildpack.\n - (Optional) To specify a Dockerfile target or build arguments, click **Show Advanced Build Settings** and then specify the target or arguments.\n - (Optional) To specify a custom service name, container image URL, container port, identity for the service to use, number of dedicated CPUs, or amount of memory to allocate to each container instance, click **Show Advanced Service Settings** and then specify the values.\n - (Optional) To specify any [environment variables](/code/docs/vscode/develop-service#optional_customizing_your_configuration), click **Show Advanced Service Settings** , click **Environment Variables**, and then specify the values.\n - (Optional) To specify Cloud SQL connections, click **Connections** and then specify one connection per line.\n - (Optional) To have VS Code reestablish a debugging session after you save a change to your code, check the **Automatically re-build and re-run on changes** checkbox.\n\n If you want to further customize how your service is run, you can edit\n [your `launch.json` file](/code/docs/vscode/develop-service#customizing_an_existing_launchjson_configuration)\n directly.\n3. To begin debugging your service, click **Debug**.\n\n4. If prompted, [authenticate your credentials to run and debug an\n application locally](/code/docs/vscode/install#authenticate_credentials_for_debugging_applications_locally).\n\n5. For each debuggable container in your service, confirm or enter the directory\n in the remote container where the program you'd like to debug is found.\n\n Alternatively, you can press `ESC` to skip debugging a container.\n\n Cloud Code attaches a debug session for each debuggable\n container in the service.\n\n\n By default, when you save a change to your application,\n Cloud Code redeploys your application and sets up a new debug\n session. You can toggle this feature with the `watch` flag in your project's\n launch configuration.\n\n6. To add a breakpoint, click in the editor margin of the file you're debugging.\n\n Red filled circles signify active breakpoints and gray hollow circles\n signify disabled breakpoints.\n\n For finer breakpoint control, you can use the Breakpoints section in VS\n Code's Debug view.\n\n When you send a new request to your service, it pauses at the line you\n specified.\n7. After your session completes, right-click to use the following commands:\n\n - **View Logs:** Open the application logs of a specific deployment with the Cloud Code Logs Explorer\n - **Open URL:** Open the application service URL of a specific service in a web browser\n8. If you've turned off watch mode in your launch configuration and you want to\n make changes to your application and rebuild and redeploy the application,\n click the Cloud Code status bar and then click\n **Turn on watch mode**.\n\n9. If you want to inspect variables and stack info, use the\n [Debug Sidebar](https://code.visualstudio.com/Docs/editor/debugging).\n To interact with the debugging session, use the\n [Debug Console](https://code.visualstudio.com/Docs/editor/debugging#_debug-console-repl)\n in the bottom pane debugger.\n\n10. To stop your deployment, click the **Stop** button in the action bar for your\n current deployment.\n\n### Troubleshoot container-building issues\n\nIf you're getting the `BUILD_DOCKER_UNKNOWN` error code, this indicates a\nproblem with Docker. To resolve this issue, perform one or more of the following\ntasks:\n\n- Restart Docker and try building the container again.\n\n- If you're still getting the same error after restarting, Docker could be\n running out of disk space. To learn more about cleaning up unused objects in\n Docker, see [Prune unused Docker objects](https://docs.docker.com/config/pruning/#prune-unused-docker-objects).\n\n- Try Docker's [Disk Usage](https://hub.docker.com/extensions/docker/disk-usage-extension)\n extension to help reclaim space.\n\nConfiguration details\n---------------------\n\nCloud Code handles the following language-specific configuration\ndetails: \n\n### Node.js\n\nRewriting the entrypoint to invoke:\n\n`node --inspect=localhost:9229`\n\n### Python\n\nInstalling the `ptvsd` module using an Init Container and rewriting the\nentrypoint to invoke:\n\n`python -m ptvsd --host localhost --port 5678`\n\n### Go\n\nInstalling the\n[`dlv` debugger](https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv.md)\nusing an Init Container and rewriting the entrypoint such that the launched\ndebug session runs with a debug server only (in headless mode), continues the\ndebugged process on start, accepts multiple client connections, and listens at\n`localhost:56268`:\n\n`dlv exec --headless --continue --accept-multiclient --listen=localhost:56268 --api-version=2, \u003capp\u003e --`\n\n### Java\n\nAdding an environment `JAVA_TOOLS_OPTIONS` with the appropriate Java Debug\nWire Protocol (JDWP) configuration such that the JDWP debugging agent listens\nfor a socket connection on port 5005 and allows the VM to begin executing\nbefore the debugger is attached:\n\n`jdwp=transport=dt_socket,server=y,suspend=n,address=5005,quiet=y`\n\n### .NET\n\n.NET Core applications are configured to be deployed along with `vsdbg` for VS\nCode.\n\nIf you encounter problems with the automatic configuration, see\n[Detailed debugger configuration and setup](https://skaffold.dev/docs/workflows/debug/#detailed-debugger-configuration-and-setup)\nfor help troubleshooting.\n\nGet Support\n-----------\n\nTo send feedback, report issues on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-vscode/issues), or ask a question on [Stack Overflow](https://stackoverflow.com/questions/ask?tags=cloud-code-vscode)."]]