Creating Debian OS and Installing Docker on GCP Platform
Creating Debian OS
After logging into the GCP platform, select on the left menu:
Compute Engine > VM Instances
Click the 'Create Instance' button at the top.
Fill in the basic instance information and configure the region, machine settings, advanced options, etc., according to your needs and budget.
Pay attention to two main points:
- Choose Debian OS for the boot disk image; if using Ubuntu OS, some commands may differ.
- Make sure to select 'Allow HTTP traffic' and 'Allow HTTPS traffic' in the firewall settings.
Click 'Create,' wait for the instance creation to complete, then click 'SSH' connection > choose 'Open in browser window' to enter the VM instance.
Next, configure local SSH connection keys; this step is optional, as you can also directly use the browser window for SSH connection.
# Note: For ease of explanation in the following steps, no password is set here. It is recommended to set a password in practice.
# <user-name> is your username.
# <server-name> is your server name.
ssh-keygen -m PEM -t rsa -f ~/.ssh/ssh-key -C <user-name>@<server-name> -b 4096
Copy the ssh-key file to your local machine, and copy the content of the ssh-key.pub file to
Compute Engine > Metadata > SSH Keys
Now, you can close the browser window connection and use SSH to connect to the GCP VM instance locally.
Open the local terminal and enter the following command to connect to the GCP VM instance:
# <user-name> is your username.
# <server-ip> is your server IP.
ssh -i ssh-key <user-name>@<server-ip>
Installing Docker
# Update the apt package repository.
sudo apt-get update
# Install necessary packages.
sudo apt-get install ca-certificates curl
# Create the keyring folder and set permissions.
sudo install -m 0755 -d /etc/apt/keyrings
# Download the public key.
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
# Set permissions.
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Set up the repository.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update the apt package repository.
sudo apt-get update
# Install Docker.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin