-
Download and Install Docker:
- Visit Docker's official site and follow the installation instructions for your operating system.
-
Verify Docker Installation:
docker --version
Warning
If you run docker with sudo, you also need to auth as root. Or docker won't be able to get your credentials!
To allow your user to run Docker commands without needing sudo
.
sudo groupadd docker
sudo usermod -aG docker $USER
Log out of your current session and log back in for the group membership changes to take effect.
docker run hello-world
If successful, Docker is configured to run without sudo
.
-
Download and Install Google Cloud SDK:
- Visit Google Cloud SDK's official site and follow the installation instructions for your operating system.
-
Verify the SDK Installation:
gcloud --version
-
Initialize the SDK:
gcloud init
-
Follow the Prompts to:
- Log in to your Google account.
- Select your Google Cloud project.
- Set the default region and zone.
-
Enable the API for Your Project:
gcloud services enable containerregistry.googleapis.com
-
Configure Docker to Use gcloud as a Credential Helper:
gcloud auth configure-docker
-
Build Your Docker Image as Usual:
docker build -t my-image .
-
Tag the Image with a GCR Registry Name:
docker tag my-image gcr.io/your-project-id/my-image:latest
Replace
your-project-id
with your actual Google Cloud project ID, andmy-image:latest
with your image name and desired tag.
-
Push the Tagged Image to GCR:
docker push gcr.io/your-project-id/my-image:latest
-
List Images in Your Project’s GCR:
gcloud container images list
-
View Image Details:
gcloud container images list-tags gcr.io/your-project-id/my-image
-
Ensure Your User Is in the Docker Group:
groups $USER
You should see
docker
listed among the groups. -
Restart the Docker Service:
sudo systemctl restart docker
-
Reboot Your System (if necessary):
- Sometimes a full system reboot is required for the changes to take effect.