Skip to content
  • Home
  • BLOG
    • Articles
    • Cloud
    • Database
    • DevOps Tools
    • Fusion Middleware
    • News
    • Operating system
    • Others
    • Scripts
  • ABOUT ME
  • CONTACT US
Osama Mustafa وَمَا تَوْفِيقِي إِلَّا بِاللَّهِ

Technology Geek

For the people who think differently Welcome aboard

Tag: Google Account

Storing Container Data in Google Cloud Storage

Posted on July 2, 2021 by Osama Mustafa in DevOps Tools

I am posting about docker a lot recently because these blog post been in my Drafts for long time waiting someone to finish them 😅 and Finally I had chance to do that.

I posted recently about storing container data in AWS s3 , but this time the same topic but for Google Cloud and how to configure that.

Configuration

  • Export some Linux variables to save time.
export projnum=$(curl http://metadata.google.internal/computeMetadata/v1/project/numeric-project-id -sH "Metadata-Flavor: Google")

 export BUCKET="Osama-${projnum}"
  • Verify that the variable was set successfully
echo $projnum
echo $BUCKET
  • Prepare the cloud storage, using gsutil, create a new bucket
gsutil mb -l us-central1 -c standard gs://$BUCKET
  • Install gcsfuse
sudo yum install -y gcsfuse
  • Update the fuse.conf file to allow the user to mount the bucket properly
sudo sed -ri 's/# user_allow_other/user_allow_other/' /etc/fuse.conf
  • Configure the directories needed to mount the bucket
 sudo mkdir /mnt/Osama /tmp/gcs
  • Change ownership of the directories to the Current user if you choose to skip this step then you will not have access
sudo chown Osama: /mnt/Osama/ /tmp/gcs
  • Mount the bucket
gcsfuse -o allow_other --temp-dir=/tmp/gcs $BUCKET /mnt/Osama/
  • Copy the website files into the bucket by copy Command
  • List the contents of the bucket
gsutil ls gs://$BUCKET

Use Bucket inside the container

  • Mount the directory into the Docker container
docker run -d --name web1 --mount type=bind,source=/mnt/Osama,target=/usr/local/apache2/htdocs,readonly -p 80:80 httpd:2.4

Enjoy

Simple and Fun 😉

Osama

Tagged DevOps, Docker, GCP, GKE, Google Account, Google CloudLeave a comment

Follow me on Twitter

My Tweets

Follow Me

  • Twitter
  • LinkedIn
  • YouTube
  • Instagram
Blog at WordPress.com.
  • Follow Following
    • Technology Geek
    • Join 2,368 other followers
    • Already have a WordPress.com account? Log in now.
    • Technology Geek
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar