Se estiver a usar um sistema operativo baseado em Linux, como o Ubuntu ou o Debian, adicione o seu nome de utilizador ao grupo docker para poder executar o Docker sem usar sudo:
sudousermod-a-Gdocker${USER}
Pode ter de reiniciar o sistema depois de se adicionar ao grupo docker.
Abra o Docker. Para garantir que o Docker está em execução, execute o seguinte comando do Docker, que devolve a data e a hora atuais:
docker run busybox date
Use gcloud como o auxiliar de credenciais para o Docker:
gcloud auth configure-docker
Opcional: se quiser executar o contentor com a GPU localmente,
instale
nvidia-docker.
Crie o seu contentor
Siga estes passos para criar o seu contentor.
Para ver uma lista dos contentores disponíveis:
gcloud container images list \
--repository="gcr.io/deeplearning-platform-release"
Recomendamos que aceda a Escolher um contentor
para ajudar a selecionar o contentor pretendido.
Se não precisar de usar um contentor com GPU, introduza o seguinte exemplo de código. Substitua tf-cpu.1-13 pelo nome do contentor que quer usar.
docker run -d -p 8080:8080 -v /path/to/local/dir:/home/jupyter \
gcr.io/deeplearning-platform-release/tf-cpu.1-13
Se quiser usar um contentor com GPU, introduza o seguinte código de exemplo. Substitua tf-gpu.1-13 pelo nome do contentor que quer usar.
docker run --runtime=nvidia -d -p 8080:8080 -v /path/to/local/dir:/home/jupyter \
gcr.io/deeplearning-platform-release/tf-gpu.1-13
Este comando inicia o contentor no modo separado, monta o diretório /path/to/local/dir local em /home/jupyter no contentor e mapeia a porta 8080 no contentor para a porta 8080 na sua máquina local. O contentor está pré-configurado para iniciar um servidor JupyterLab, que pode visitar em http://localhost:8080.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-21 UTC."],[[["\u003cp\u003eThis guide details the process of creating and setting up a local deep learning container, requiring basic Docker knowledge.\u003c/p\u003e\n"],["\u003cp\u003eThe setup involves creating or selecting a Google Cloud project, installing and initializing the gcloud CLI, and installing Docker, with specific instructions for Linux users to avoid using \u003ccode\u003esudo\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eUsers can choose from available deep learning containers using a command to list them or visit the "Choosing a container" page, then using a command to either use a cpu container, or a gpu-enabled container.\u003c/p\u003e\n"],["\u003cp\u003eThe container is launched in detached mode, mounting a local directory to the container and mapping a port, which then allows the user to use a preconfigured JupyterLab server.\u003c/p\u003e\n"],["\u003cp\u003eOptionally, for those requiring GPU acceleration, the guide suggests installing \u003ccode\u003envidia-docker\u003c/code\u003e, and using the appropriate container creation command.\u003c/p\u003e\n"]]],[],null,["# Get started with a local deep learning container\n\nThis page describes how to create and set up a local deep learning container.\nThis guide expects you to have basic familiarity\nwith [Docker](https://www.docker.com/).\n\nBefore you begin\n----------------\n\nComplete the following steps to set up a Google Cloud account, enable\nthe required APIs, and install and activate the required software.\n\n1. In the Google Cloud Console, go to the **Manage resources** page\n and select or create a project.\n\n | **Note:** If you don't plan to keep the resources you create in this tutorial, create a new project instead of selecting an existing project. After you finish, you can delete the project, removing all resources associated with the project and tutorial.\n\n [Go to Manage\n resources](https://console.cloud.google.com/cloud-resource-manager)\n2. [Install and initialize the\n gcloud CLI](/sdk/docs).\n\n3. [Install Docker](https://docs.docker.com/install/).\n\n If you're using a Linux-based operating system, such as Ubuntu or Debian,\n add your username to the `docker` group so that you can run Docker\n without using `sudo`: \n\n sudo usermod -a -G docker ${USER}\n\n | **Caution:** The `docker` group is equivalent to the `root` user. See [Docker's documentation](https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface) for details on how this affects the security of your system.\n\n You may need to restart your system after adding yourself to\n the `docker` group.\n4. Open Docker. To ensure that Docker is running, run the following\n Docker command, which returns the current time and date:\n\n docker run busybox date\n\n5. Use `gcloud` as the credential helper for Docker:\n\n gcloud auth configure-docker\n\n6. **Optional** : If you want to run the container using GPU locally,\n install\n [`nvidia-docker`](https://github.com/NVIDIA/nvidia-docker#quickstart).\n\nCreate your container\n---------------------\n\nFollow these steps to create your container.\n\n1. To view a list of containers available:\n\n gcloud container images list \\\n --repository=\"gcr.io/deeplearning-platform-release\"\n\n You may want to go to [Choosing a container](/deep-learning-containers/docs/choosing-container)\n to help you select the container that you want.\n2. If you don't need to use a GPU-enabled container, enter the following code\n example. Replace \u003cvar translate=\"no\"\u003etf-cpu.1-13\u003c/var\u003e with the name of the container\n that you want to use.\n\n docker run -d -p 8080:8080 -v /path/to/local/dir:/home/jupyter \\\n gcr.io/deeplearning-platform-release/\u003cvar translate=\"no\"\u003etf-cpu.1-13\u003c/var\u003e\n\n If you want to use a GPU-enabled container, enter the following code\n example. Replace \u003cvar translate=\"no\"\u003etf-gpu.1-13\u003c/var\u003e with the name of the container\n that you want to use. \n\n docker run --runtime=nvidia -d -p 8080:8080 -v /path/to/local/dir:/home/jupyter \\\n gcr.io/deeplearning-platform-release/\u003cvar translate=\"no\"\u003etf-gpu.1-13\u003c/var\u003e\n\nThis command starts up the container in detached mode, mounts the local\ndirectory `/path/to/local/dir` to `/home/jupyter` in the container, and maps\nport 8080 on the container to port 8080 on your local machine. The\ncontainer is preconfigured to start a JupyterLab server, which you can\nvisit at `http://localhost:8080`.\n\nWhat's next\n-----------\n\n- Learn more about how to work with containers in the [Docker\n documentation](https://docs.docker.com)."]]