Skip to main content

Local Emulator for Google Cloud Storage

CI PyPI codecov Code style: black

Google doesn't (yet) ship an emulator for the Cloud Storage API like they do for Cloud Datastore.

This is a stub emulator so you can run your tests and do local development without having to connect to the production Storage APIs.

THIS IS A WORK IN PROGRESS AND ONLY SUPPORTS A LIMITED SUBSET OF THE API


Installation

pip install gcp-storage-emulator

CLI Usage

Starting the emulator

Start the emulator with:

gcp-storage-emulator start

By default, the server will listen on http://localhost:9023 and data is stored under ./.cloudstorage. You can configure the folder using the env variables STORAGE_BASE (default ./) and STORAGE_DIR (default .cloudstorage).

If you wish to run the emulator in a testing environment or if you don't want to persist any data, you can use the --in-memory parameter. For tests, you might want to consider starting up the server from your code (see the Python APIs)

If you're using the Google client library (e.g. google-cloud-storage for Python) then you can set the STORAGE_EMULATOR_HOST environment variable to tell the library to connect to your emulator endpoint rather than the standard https://storage.googleapis.com, e.g.:

export STORAGE_EMULATOR_HOST=http://localhost:9023

Wiping data

You can wipe the data by running

gcp-storage-emulator wipe

You can pass --keep-buckets to wipe the data while keeping the buckets.

Example

Use in-memory storage and automatically create default storage bucket my-bucket.

gcp-storage-emulator start --host=localhost --port=9023 --in-memory --default-bucket=my-bucket

Python APIs

To start a server from your code you can do

from gcp_storage_emulator.server import create_server

server = create_server("localhost", 9023, in_memory=False)

server.start()
# ........
server.stop()

You can wipe the data by calling server.wipe()

This can also be achieved (e.g. during tests) by hitting the /wipe HTTP endpoint

Example

import os

from google.cloud import storage
from gcp_storage_emulator.server import create_server

HOST = "localhost"
PORT = 9023
BUCKET = "test-bucket"

# default_bucket parameter creates the bucket automatically
server = create_server(HOST, PORT, in_memory=True, default_bucket=BUCKET)
server.start()

os.environ["STORAGE_EMULATOR_HOST"] = f"http://{HOST}:{PORT}"
client = storage.Client()

bucket = client.bucket(BUCKET)
blob = bucket.blob("blob1")
blob.upload_from_string("test1")
blob = bucket.blob("blob2")
blob.upload_from_string("test2")
for blob in bucket.list_blobs():
    content = blob.download_as_bytes()
    print(f"Blob [{blob.name}]: {content}")

server.stop()

Docker

Pull the Docker image.

docker pull oittaa/gcp-storage-emulator

Inside the container instance, the value of the PORT environment variable always reflects the port to which requests are sent. It defaults to 8080. The directory used for the emulated storage is located under /storage in the container. In the following example the host's directory $(pwd)/cloudstorage will be bound to the emulated storage.

docker run -d \
  -e PORT=9023 \
  -p 9023:9023 \
  --name gcp-storage-emulator \
  -v "$(pwd)/cloudstorage":/storage \
  oittaa/gcp-storage-emulator
import os

from google.cloud import exceptions, storage

HOST = "localhost"
PORT = 9023
BUCKET = "test-bucket"

os.environ["STORAGE_EMULATOR_HOST"] = f"http://{HOST}:{PORT}"
client = storage.Client()

try:
    bucket = client.create_bucket(BUCKET)
except exceptions.Conflict:
    bucket = client.bucket(BUCKET)

blob = bucket.blob("blob1")
blob.upload_from_string("test1")
print(blob.download_as_bytes())

Metadata

Release files for gcp-storage-emulator 2026.7.19

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gcp-storage-emulator 2026.7.19
File Size Uploaded
gcp_storage_emulator-2026.7.19.tar.gz 41.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gcp-storage-emulator 2026.7.19
File Interpreter ABI Platform
gcp_storage_emulator-2026.7.19-py3-none-any.whl Python 3 none any Details

Total release size: 71.1 kB

Release files / gcp_storage_emulator-2026.7.19.tar.gz

Download URL gcp_storage_emulator-2026.7.19.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
573a5eb2b413d338b3aa6c6bee383a9837fd000a6a2efb698bab5b0dfaa1271f
BLAKE2b-256 checksum
How to use checksums
0c8c50d2a4d182100c6a424815ed9e02395c3760e3ecdb2738ecc4fee4b9ce1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release files / gcp_storage_emulator-2026.7.19-py3-none-any.whl

Download URL gcp_storage_emulator-2026.7.19-py3-none-any.whl
Size 29.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b60145057fdfa7751259f68758c3a1df919f4bf6fad21dd2fa2559b3f6273241
BLAKE2b-256 checksum
How to use checksums
2767518fd13beb02f65579a26b7d7dd45a551b55faca9a6019c645e218efba2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page