- Download Gcloud SDK from this link and install it according to the instructions for your OS.
- Initialize the SDK following these instructions.
- Run
gcloud init
from a terminal and follow the instructions. - Make sure that your project is selected with the command
gcloud config list
- Run
- From your project's dashboard, go to Cloud Compute > VM instance
- Create a new instance with this config:
- Any name of your choosing
- Pick your favourite region. You can check out the regions iin this link.
- Pick a E2 series instance. A e2-standard-4 instance is recommended (4 vCPUs, 16GB RAM)
- Change the boot disk to Ubuntu. The Ubuntu 20.04 LTS version is recommended. Also pick at least 30GB of storage.
- Leave all other settings on their default value and click on Create.
- When you create an instance, it will be started automatically. You can skip to step 3 of the next section.
- Start your instance from the VM instances dashboard.
- In your local terminal, make sure that gcloud SDK is configured for your project. Use
gcloud config list
to list your current config's details.- If you have multiple google accounts but the current config does not match the account you want:
- Use
gcloud config configurations list
to see all of the available configs and their associated accounts. - Change to the config you want with
gcloud config configurations activate [name of project]
- Use
- If the config matches your account but points to a different project:
- Use
gcloud projects list
to list the projects available to your account (it can take a while to load). - use
gcloud config set project [name of project]
to change your current config to your project.
- Use
- If you have multiple google accounts but the current config does not match the account you want:
- Set up the SSH connection to your VM instances with
gcloud compute config-ssh
- Inside
~/ssh/
a newconfig
file should appear with the necessary info to connect. - If you did not have a SSH key, a pair of public and private SSH keys will be generated for you.
- The output of this command will give you the host name of your instance in this format:
instance.zone.project
; write it down. - If you experience the following permission issue
Required 'compute.projects.setCommonInstanceMetadata' permission
, you may need to add the following IAM Roles to your service account to set up the SSH keys.- Compute Admin
- Service Account User
- In total you will have 6 IAM roles configured.
- Inside
- You should now be able to open a terminal and SSH to your VM instance like this:
ssh instance.zone.project
- In VSCode, with the Remote SSH extension, if you run the command palette and look for Remote-SSH: Connect to Host (or alternatively you click on the Remote SSH icon on the bottom left corner and click on Connect to Host), your instance should now be listed. Select it to connect to it and work remotely.
- VSCode may return an error for
Permission denied (publickey).
. You may resolve this by ensuring that the SSH config file correctly lists the Hostname and User which may be your Windows AD login. - Alternatively, continue by launching the VM in your browser from the GCP portal.
... [22:19:19.119] > ca\\[email protected]: Permission denied (publickey). [22:19:19.143] > The process tried to write to a nonexistent pipe. ...
- VSCode may return an error for
- Run this first in your SSH session:
sudo apt update && sudo apt -y upgrade
- It's a good idea to run this command often, once per day or every few days, to keep your VM up to date.
- In your local browser, go to the Anaconda download page, scroll to the bottom, right click on the 64 bit x86 installer link under Linux and copy the URL.
- At the time of writing this gist, the URL is https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
- In your SSH session, type
wget <anaconda_url>
to download the installer.- For example:
wget https://repo.anaconda.com/archive/Anaconda3-2021.11-Linux-x86_64.sh
- For example:
- Find the filename of the installer with
ls
- Run the installer with
bash <filename>
(you can start typing the name and then press the Tab key to autocomplete) - Follow the on-screen instructions. Answer
yes
to all yes/no questions and leave all other default values. - Log out of your current SSH session with
exit
and log back in.- You should now see a
(base)
at the beginning of your command prompt.
- You should now see a
- You may now remove the Anaconda installer with
rm <filename>
.- For example:
rm Anaconda3-2021.11-Linux-x86_64.sh
- For example:
- Run
sudo apt install docker.io
to install it. - Change your settings so that you can run Docker without
sudo
:- Run
sudo groupadd docker
- Run
sudo gpasswd -a $USER docker
- Log out of your SSH session with
exit
and log back in. - Run
sudo service docker restart
- Test that Docker can run successfully with
docker run hello-world
- Run
- Run
- Now to install Docker Compose:
- Go to https://github.com/docker/compose/releases and copy the URL for the
docker-compose-linux-x86_64
binary for its latest version.- At the time of writing, the last available version is
v2.2.3
and the URL for it is https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64
- At the time of writing, the last available version is
- Create a folder for binary files for your Linux user:
- Create a subfolder
bin
in your home account withmkdir ~/bin
- Go to the folder with
cd ~/bin
- Download the binary file with
wget <compose_url> -O docker-compose
- If you forget to add the
-O
option, you can rename the file withmv <long_filename> docker-compose
- For example:
wget https://github.com/docker/compose/releases/download/v2.2.3/docker-compose-linux-x86_64 -O docker-compose
- If you forget to add the
- Make sure that the
docker-compose
file is in the folder withls
- Make the binary executable with
chmod +x docker-compose
- Check the file with
ls
again; it should now be colored green. You should now be able to run it with./docker-compose version
- Go back to the home folder with
cd ~
- Run
nano .bashrc
to modify your path environment variable:- Scroll to the end of the file
- You can use the down arrow to scroll manually to the bottom and you may need to alt tab back to the VM window to confirm your cursor position
- Add this line at the end:
export PATH="${HOME}/bin:${PATH}"
- Press
CTRL
+o
in your keyboard to save the file. - Press
Enter
. - Press
CTRL
+x
in your keyboard to exit the Nano editor.
- Scroll to the end of the file
- Reload the path environment variable with
source .bashrc
- You should now be able to run Docker compose from anywhere; test it with
docker-compose version
- Create a subfolder
- Go to https://github.com/docker/compose/releases and copy the URL for the
- Run
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
- Run
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
- Run
sudo apt-get update && sudo apt-get install terraform
- Check the installation with
terraform version