Desarrolla una app de Kubernetes con el desarrollo remoto
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
En esta página, se explica cómo usar Cloud Code para el desarrollo remoto de VS Code, es decir, para abrir tu base de código en un contenedor remoto en el que se compila, depura e implementa tu aplicación. Esto crea una aplicación portátil, sin importar el SO de tu máquina de desarrollo.
Para configurar una carpeta .devcontainer con un Dockerfile y un archivo Devcontainer.json configurados para el idioma que usas, haz clic en Open a Remote Window > Add Dev Container Config Files.
Como alternativa, puedes seguir los pasos que se indican en Desarrollo remoto en contenedores.
Después de seguir las indicaciones, tu lugar de trabajo incluirá lo siguiente:
Dockerfile: Define una imagen de contenedor que contiene las herramientas para desarrolladores que se instalarán en un contenedor de desarrollo remoto.
Devcontainer.json: Le indica a la extensión de herramientas remotas de VS Code cómo ejecutar el contenedor de desarrollo remoto.
Abre el Dockerfile y agrega instrucciones para instalar Google Cloud CLI y Skaffold. Para obtener comandos actualizados, consulta las guías de instalación.
En el Dockerfile, agrega instrucciones para copiar las configuraciones de la CLI de gcloud y Skaffold de localhost antes del comando >> $HOME/.bashrc. Como alternativa, puedes volver a escribir los comandos para instalar la CLI de gcloud y Skaffold.
# Copy localhost's ~/.kube/config file into the container and swap out localhost
# for host.docker.internal whenever a new shell starts to keep them in sync.
RUN echo '\n\
if [ "$SYNC_LOCALHOST_KUBECONFIG" == "true" ]; then\n\
mkdir -p $HOME/.kube\n\
cp -r $HOME/.kube-localhost/* $HOME/.kube\n\
sed -i -e "s/localhost/host.docker.internal/g" $HOME/.kube/config\n\
\n\
fi' \
if [ "$SYNC_LOCALHOST_GCLOUD" == "true" ]; then\n\
mkdir -p $HOME/.config/gcloud\n\
cp -r $HOME/.gcloud-localhost/* $HOME/.config/gcloud\n\
\n\
fi' \
Abre el archivo Devcontainer.json y agrega los siguientes argumentos de ejecución para
copiar las configuraciones de gcloud CLI y Skaffold desde localhost:
Una vez que tus archivos tengan el contenido requerido, haz clic en Abrir una ventana remota.
Ejemplo de archivo devcontainer.json
El archivo devcontainer.json le indica a la extensión de contenedor remoto qué puertos exponer en el contenedor, cómo activar las unidades y qué extensiones instalar en el contenedor remoto. En el siguiente archivo devcontainer.json de muestra, se especifica que la extensión de contenedor remoto debe instalar la extensión de Cloud Code para VS Code:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-05 (UTC)"],[[["\u003cp\u003eThis guide outlines how to use Cloud Code for VS Code with Remote Development, enabling the building, debugging, and deployment of applications within a portable remote container.\u003c/p\u003e\n"],["\u003cp\u003eSetting up involves configuring a \u003ccode\u003e.devcontainer\u003c/code\u003e folder with a Dockerfile and \u003ccode\u003eDevcontainer.json\u003c/code\u003e file, tailored to your development language, to define the container's environment.\u003c/p\u003e\n"],["\u003cp\u003eThe Dockerfile should include instructions for installing the Google Cloud CLI and Skaffold, essential tools for working with Cloud Code, which you can add by following the official installation guides.\u003c/p\u003e\n"],["\u003cp\u003eThe process involves copying gcloud CLI and Skaffold configurations from the local host into the container, or rewriting the commands, to synchronize and maintain consistent settings between environments.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eDevcontainer.json\u003c/code\u003e file manages the container's settings like exposed ports and extensions, with an example provided that includes the installation of the Cloud Code extension.\u003c/p\u003e\n"]]],[],null,["# Develop a Kubernetes app with remote development\n\n\u003cbr /\u003e\n\nThis page explains how to use Cloud Code for VS Code\n[Remote Development](https://code.visualstudio.com/docs/remote/ssh),\nthat is, to open your codebase in a remote container where your application is\nbuilt, debugged, and deployed. This creates an application that's portable,\nregardless of the OS of your development machine.\n| **Note:** For steps to set up remote debugging on Chrome OS, see [Build a dev workflow with Cloud Code on a Pixelbook](/blog/products/application-development/build-a-dev-workflow-with-cloud-code-on-a-pixelbook).\n\nPrerequisites\n-------------\n\nIn addition to the setup described in\n[Install the Cloud Code extension](/code/docs/vscode/install),\ninstall the\n[Remote Development](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)\nVS Code extension pack.\n\nSetup\n-----\n\n1. To set up a `.devcontainer` folder with a Dockerfile and `Devcontainer.json`\n file configured for the language you're using, click\n **Open a Remote Window** \\\u003e **Add Dev Container Config Files** .\n Alternatively, you can follow the steps in\n [Remote development in Containers](https://code.visualstudio.com/docs/remote/containers-tutorial).\n\n After you follow the prompts, your workspace will include:\n - Dockerfile --- defines a container image that holds the developer tools to\n install in a remote development container.\n\n - `Devcontainer.json` --- Instructs the VS Code Remote Tools extension how to run\n the remote development container.\n\n2. Open the Dockerfile and add instructions to install the\n [Google Cloud CLI](/sdk/docs/downloads-interactive) and\n [Skaffold](https://skaffold.dev/docs/install/). For up-to-date\n commands, see the installation guides.\n\n3. In the Dockerfile, add instructions to copy localhost's\n gcloud CLI and Skaffold configs before the `\u003e\u003e $HOME/.bashrc`\n command. Alternatively,\n you can rewrite the commands to install the gcloud CLI\n and Skaffold.\n\n # Copy localhost's ~/.kube/config file into the container and swap out localhost\n # for host.docker.internal whenever a new shell starts to keep them in sync.\n RUN echo '\\n\\\n if [ \"$SYNC_LOCALHOST_KUBECONFIG\" == \"true\" ]; then\\n\\\n mkdir -p $HOME/.kube\\n\\\n cp -r $HOME/.kube-localhost/* $HOME/.kube\\n\\\n sed -i -e \"s/localhost/host.docker.internal/g\" $HOME/.kube/config\\n\\\n \\n\\\n fi' \\\n if [ \"$SYNC_LOCALHOST_GCLOUD\" == \"true\" ]; then\\n\\\n mkdir -p $HOME/.config/gcloud\\n\\\n cp -r $HOME/.gcloud-localhost/* $HOME/.config/gcloud\\n\\\n \\n\\\n fi' \\\n\n4. Open the `Devcontainer.json` file and add the following run arguments to\n copy the gcloud CLI and Skaffold configs from localhost:\n\n \"-e\", \"SYNC_LOCALHOST_KUBECONFIG=true\",\n \"-e\", \"SYNC_LOCALHOST_GCLOUD=true\",\n\n5. After your files have the required contents, click\n\n **Open a Remote Window**.\n\nSample devcontainer.json file\n-----------------------------\n\nThe `devcontainer.json` file tells the Remote Container extension which ports to\nexpose in the container, how to mount drives, and which extensions to install\nin the remote container. The following sample `devcontainer.json` file\nspecifies that the Remote Container extension should install the\nCloud Code for VS Code extension: \n\n \"runArgs\": [\n \"-v\",\"/var/run/docker.sock:/var/run/docker.sock\",\n \"--mount\", \"type=bind,source=${env:HOME}${env:USERPROFILE}/.kube,target=/root/.kube-localhost\",\n \"--mount\", \"type=bind,source=${env:HOME}${env:USERPROFILE}/.config/gcloud,target=/root/.gcloud-localhost\",\n \"-e\", \"SYNC_LOCALHOST_KUBECONFIG=true\",\n \"-e\", \"SYNC_LOCALHOST_GCLOUD=true\",\n \"--cap-add=SYS_PTRACE\", \"--security-opt\", \"seccomp=unconfined\"\n ]\n\nWhat's next\n-----------\n\n- Read the Visual Studio docs on [remote development using SSH](https://code.visualstudio.com/docs/remote/ssh).\n- Take a tutorial to [run Visual Studio Code in a docker container](https://code.visualstudio.com/docs/devcontainers/tutorial). using the Dev containers extension.\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)."]]