Posts

Docker Commands

1) Run a container docker run <container id> 2) List all the running containers docker ps 3) List all the containers present docker ps—a 4) Stop the container docker stop <container id>   Note: You can give just the first 3 letters of the container Ex: docker stop 98x 5) Remove the stopped container docker rm <container id> 6) List all the available images docker images 7) To pull a docker image docker pull <image name> 8) To check all the steps performed when the image was pulled docker history <image id> 9) Remove the images that are no longer used docker rmi <image name> 10) Run the container in detached mode docker run—d <image name> Ex: docker run —d ubuntu 11) Pull the image docker pull <image name> Ex: docker pull ubuntu 12) Execute command on a running container docker exec <container id> <command to be executed> 13) If you want a particular version of the image add the tag docker run <image name>:<version

How to grant a role on a specific CloudSQL instance?

locals {   instance_admins = {   "db-group" : "group:gcp-ccoe-sre@mycloud.io" ,   "dev-team" : "user:dp@mycloud.io"   } } resource "google_project_iam_member" "instance_admin" {   for_each = var . instance_admins   project   = "my-first-project"   role     = "roles/cloudsql.admin"   member   = each. value   condition {       title       = "cloudsql admin role for db team"       description = "cloudsql admin role for db team"       expression   = "resource.name == \" ${ google_sql_database_instance . instance . self_link } \" "   } }

Cloud Storage

 How to mount GCP Cloud Storage bucket as file system? Cloud Storage FUSE is an open source  FUSE  adapter that allows you to mount Cloud Storage buckets as file systems on Linux or macOS systems. It also provides a way for applications to upload and download Cloud Storage objects using standard file system semantics. Cloud Storage FUSE can be run anywhere with connectivity to Cloud Storage, including Google Compute Engine VMs or on-premises systems . https://cloud.google.com/storage/docs/gcs-fuse

GCP Cloud Shell

In which zone my GCP's Cloud Shell is provisioned? curl "http://metadata.google.internal/computeMetadata/v1/instance/zone" -H "Metadata-Flavor: Google" Short keys To open Cloud shell: type g followed by s Autocomplete: tab

Service accounts

  How to run gcloud command line using a service account Step-by-step 1) Create a Service Account gcloud iam service - accounts create gcpcmdlineuser  -- display - name "GCP Service Account" 2) List the users gcloud iam service - accounts list   -- filter   gcpcmdlineuser@someproject.gserviceaccount.com 3) Download the service account key gcloud iam service - accounts keys create . / somekey.json  -- iam - account <EMAIL ADDRESS> gcloud iam service - accounts keys create gcpcmdlineuser.json  -- iam - account gcpcmdlineuser@someproject.iam.gserviceaccount.com 4) Associate a ROLE gcloud iam roles create <ROLE NAME>  -- project <YOUR PROJECT ID>  -- file   . / rolename.yaml gcloud projects add - iam - policy - binding someprojecthere  -- member "serviceAccount:gcpcmdlineuser@someproject.iam.gserviceaccount.com"   -- role "roles/owner" gcloud projects add - iam - policy - binding <PROJECT ID>  -- role <ROLE NAME>  -- member servic