Marny Lopez (iMrLopez)

Software Engineer




Marny Lopez (iMrLopez)

Software Engineer




Blog Post

Deploying Docker Containers to The Cloud

octubre 31, 2022 Docker
Deploying Docker Containers to The Cloud

The small Docker containers are fantastic. They can run on any OS because they are essentially self-contained apps.

I’ll demonstrate how to run your application in the Cloud using a Docker container. Since you’ve put everything, you need for it to run within a Docker container, you can now run it on any Windows, Linux, or macOS system without having to install anything.

What is Docker:

Software deployment in portable containers is automated with the help of the configuration management tool Docker. Applications can operate more effectively in various contexts thanks to these containers.

Features of Docker:

·  Simple and quick configuration

·  isolation of applications

·  security oversight

·  extremely productive

·  extremely scalable

·  Infrastructure not required

Docker container

A “Docker container” software package has every dependency needed to run an application.


A simple text file called a Docker file contains instructions for creating Docker images.


# Comments

The argument for a command argument1…


# Print “Get Certified. Get Ahead”

Run echo “Get Certified. Get Ahead”

Let’s now examine the process for using a docker file to create a Docker image.

Project Setup

We keep our code under the name in a GCP-API directory (label it whatever you want). In addition to our script, we need the following:

A collection of Python modules for our Docker file to install and a Docker file serve as the guide for the Docker requirements.txt file.

We need Docker because we’re using it.

The 1:46:21 mark in this video covers Windows installation, followed by the 1:53:22 mark for macOS, in case you run into any OS-specific installation problems.

Build and Publish Container Images

We can create Docker images using Cloud Build, and all we need are our project files (which include a Docker file).

The following command creates our Docker image and pushes it to the Container Registry using Cloud Shell.

gcloud builds submit –tag<PROJECT_ID>/demo-image.

Replace <PROJECT_ID> with your actual project ID value.

It should be noted that you can pass a timeout parameter, for example: –timeout=600s

Deploy with Google Cloud Platform

To deploy our container to the Cloud, we must follow three steps. We start by:

Download the Google Cloud SDK, which you’ll need to utilize Cloud Build to create our container.

The container is to the Container Registry of GCP.

Use Cloud Run to deploy it.

GCloud SDK

The SDK installation can be found here. Once it has been set up, we must verify our GCloud SDK by opening the CMD prompt (or your equivalent CLI) and entering the following command:

gcloud auth login

With the help of this command, our web browser is opened, enabling us to log into Google Cloud as usual. We set up Docker to use our GCP login information with the following:

gcloud auth configure-docker

Set the active project to your project ID by doing the following:

gcloud config set project

Cloud-Based Container Assembly and Registry

We can use Docker containers as a launchpad for our deployments thanks to the Google Container Registry (GCR) service, which enables us to store Docker containers.

To launch our container, we require an already-running project—an image created by the Author.

Creating a project is a prerequisite for using GCR or other services GCP offers. To accomplish this, open the Google Cloud Platform dashboard, go to the project selector page, and click the Create Project button.

Getting a new project up and running is a straightforward process—an image created by the Author.

For us to use GCR in a project for the first time, the GCR API must be enabled. The Author took the photo.

Since we have our project up and running, we should be able to access the Container Registry. In the top bar, we should be able to see the name of the newly formed project we are working on here.

To use GCR, we need to click the Enable Container Registry API button in the middle of the terminal window.

Finally, we can now upload our container to GCR by submitting it to Cloud Build, a service offered by GCP that generates Docker containers.

To accomplish this, we open our command line interface (CLI) in the directory containing our project and type: Cloud builds submit –tag[PROJECT-ID]/GCP-API

·  gcloud builds submit the Docker image currently linked to our working directory to Cloud Build so that it can be incorporated into a container there.

The location of our Container Registry is communicated to the flag –tag in the following manner:

· is the GCR hostname.

·  [PROJECT-ID] is our project ID

·  GCP-API is our image name.

The GCP-API project that we are working on in Container Registry. Image created by the Author.

If we reload the GCR window, we should be able to view the newly uploaded Docker image that we have been working on. If it isn’t there yet, it is most likely still in the process of being built, which may be viewed on the dashboard of our Cloud Build environment.

Cloud Run

Since our Docker container is now complete, we can proceed with deploying it using Cloud Run.

A procedure is broken down into individual steps for deploying containers using Cloud Run. Image created by the Author.

In the interface for Cloud Run, the deployment process consists of the following steps: (1) clicking the Create Service button, (2) configuring our deployment, (3)– (4) choosing the container, and (5) creating our deployment!

A deployment that is currently being worked on in Cloud Run. Image created by the Author.

Within what ought to be no more than a few minutes, we will be able to view the deployment status on the Cloud Run console.

After it is finished, a checkmark in green text and a URL will show next to the name of our deployment and the location. The Author took the photo.

When the process is finished, we will see a checkmark in green next to our deployment name, and the URL of our deployment will be next to that.


We successfully deployed our Python application to the web using Google Cloud by packaging it into a Docker container and then putting it online.

Docker and Google Cloud Platform (GCP) are two excellent tools that make the process simple and straightforward, which, in most cases, leads to perfect deployments time and time again.

Now, more than ever before in the history of humanity. We can take the thoughts and ideas floating about in our heads and give them a physical form in the world around us, which can lead to the production of some very incredible works of art.

Write a comment