Google Cloud Storage emulator & testing library.
Find a file
dependabot[bot] 23b51b96f1
build(deps): bump cloud.google.com/go/storage from 1.62.0 to 1.62.1 (#2206)
Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.62.0 to 1.62.1.
- [Release notes](https://github.com/googleapis/google-cloud-go/releases)
- [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md)
- [Commits](https://github.com/googleapis/google-cloud-go/compare/spanner/v1.62.0...storage/v1.62.1)

---
updated-dependencies:
- dependency-name: cloud.google.com/go/storage
  dependency-version: 1.62.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-20 03:29:29 +00:00
.github build(deps): bump docker/build-push-action from 7.0.0 to 7.1.0 (#2203) 2026-04-12 19:35:53 -04:00
ci Added support from gcloud cli resumable uploads (#1976) 2026-02-04 03:07:24 -05:00
examples build(deps): bump go.opentelemetry.io/otel/sdk in /examples/go (#2201) 2026-04-12 19:36:02 -04:00
fakestorage Add runtime per-bucket pub/sub notification configuration API (#2157) 2026-03-31 00:26:24 -04:00
internal Add runtime per-bucket pub/sub notification configuration API (#2157) 2026-03-31 00:26:24 -04:00
testdata github/workflows/main: add windows to CI (#229) 2020-04-30 17:23:52 -04:00
.dockerignore Initial object versioning support - retention of old generations if version is enabled, and getObject by generation (#60) 2019-12-11 22:14:09 -05:00
.gitattributes github/workflows/main: add windows to CI (#229) 2020-04-30 17:23:52 -04:00
.gitignore main: make server configurable 2019-07-18 17:33:52 -04:00
.golangci.yaml build(deps): bump golangci/golangci-lint-action from 6.5.1 to 7.0.0 (#1940) 2025-05-12 10:58:21 -04:00
CLAUDE.md docs: add CLAUDE.md for Claude Code guidance 2026-01-31 00:09:49 +00:00
Dockerfile build(deps): bump alpine from 3.23.3 to 3.23.4 (#2209) 2026-04-19 23:19:14 -04:00
go.mod build(deps): bump cloud.google.com/go/storage from 1.62.0 to 1.62.1 (#2206) 2026-04-20 03:29:29 +00:00
go.sum build(deps): bump cloud.google.com/go/storage from 1.62.0 to 1.62.1 (#2206) 2026-04-20 03:29:29 +00:00
LICENSE license: remove the year 2022-01-25 09:45:07 -05:00
main.go Enable HTTP/2 (#2004) 2025-08-24 23:05:27 -04:00
README.md Add environment variable support for all configuration options (#1925) 2026-02-13 23:48:57 -05:00

fake-gcs-server

Build Status GoDoc

fake-gcs-server provides an emulator for Google Cloud Storage API. It can be used as a library in Go projects and/or as a standalone binary/Docker image.

The library is available inside the package github.com/fsouza/fake-gcs-server/fakestorage and can be used from within test suites in Go package. The emulator is available as a binary that can be built manually, downloaded from the releases page or pulled from Docker Hub (docker pull fsouza/fake-gcs-server).

Using the emulator in Docker

You can stub/mock Google Cloud Storage as a standalone server (like the datastore/pubsub emulators) which is ideal for integration tests and/or tests in other languages you may want to run the fake-gcs-server inside a Docker container:

docker run -d --name fake-gcs-server -p 4443:4443 fsouza/fake-gcs-server

Preload data

In case you want to preload some data in fake-gcs-server just mount a folder in the container at /data:

docker run -d --name fake-gcs-server -p 4443:4443 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server

Where the content of ${PWD}/examples/data is something like:

.
└── sample-bucket
    └── some_file.txt

To make sure everything works as expected you can execute these commands:

curl --insecure https://0.0.0.0:4443/storage/v1/b
{"kind":"storage#buckets","items":[{"kind":"storage#bucket","id":"sample-bucket","name":"sample-bucket"}],"prefixes":null}

curl --insecure https://0.0.0.0:4443/storage/v1/b/sample-bucket/o
{"kind":"storage#objects","items":[{"kind":"storage#object","name":"some_file.txt","id":"sample-bucket/some_file.txt","bucket":"sample-bucket","size":"33"}],"prefixes":[]}

This will result in one bucket called sample-bucket containing one object called some_file.txt.

Running with HTTP

fake-gcs-server defaults to HTTPS, but it can also be used with HTTP. The flag -scheme can be used to specify the protocol.
The binding port will be -port (defaults to 4443).
For example, the previous example could be changed to pass -scheme http:

docker run -d --name fake-gcs-server -p 4443:4443 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server -scheme http

And now we can curl it without the --insecure flag and using http:// instead of https://:

curl http://0.0.0.0:4443/storage/v1/b
{"kind":"storage#buckets","items":[{"kind":"storage#bucket","id":"sample-bucket","name":"sample-bucket"}],"prefixes":null}

curl http://0.0.0.0:4443/storage/v1/b/sample-bucket/o
{"kind":"storage#objects","items":[{"kind":"storage#object","name":"some_file.txt","id":"sample-bucket/some_file.txt","bucket":"sample-bucket","size":"33"}],"prefixes":[]}

Running with both HTTPS and HTTP

To start both HTTPS and HTTP servers, pass -scheme both.
HTTPS will bind to -port (defaults to 4443) and HTTP will bind to -port-http (defaults to 8000).
For example, the previous example could be changed to pass -scheme both:

docker run -d --name fake-gcs-server -p 4443:4443 -p 8000:8000 -v ${PWD}/examples/data:/data fsouza/fake-gcs-server -scheme both

Using with signed URLs

It is possible to use fake-gcs-server with signed URLs, although with a few caveats:

  • No validation is made on the query params (signature, expiration ...)
  • You need your client to modify the URL before passing it around (replace storage.googleapis.com with something that points to fake-gcs-server)
  • You need to configure fake-gcs-server to accept this local URL (by setting -public-host)

Available server flags

fake-gcs-server supports various features that can be configured through flags upon start. Use the -help flag to list all of them alongside their usage instructions

docker run --rm fsouza/fake-gcs-server -help

Environment Variables

All server flags can also be configured using environment variables. The environment variable names are prefixed with FAKE_GCS_ and use uppercase with underscores. For example:

  • -port: FAKE_GCS_PORT
  • -port-http: FAKE_GCS_PORT_HTTP
  • -scheme: FAKE_GCS_SCHEME
  • -backend: FAKE_GCS_BACKEND
  • -filesystem-root: FAKE_GCS_FILESYSTEM_ROOT
  • -public-host: FAKE_GCS_PUBLIC_HOST
  • -external-url: FAKE_GCS_EXTERNAL_URL

Example using environment variables:

docker run -d --name fake-gcs-server -e FAKE_GCS_SCHEME=http -p 4443:4443 fsouza/fake-gcs-server

Notes:

  • Command line flags take precedence over environment variables
  • Invalid values (e.g., non-numeric values for ports) will cause an error and the server will not start

Client library examples

For examples using SDK from multiple languages, check out the examples directory.

Building the image locally

You may use docker build to build the image locally instead of pulling it from Docker Hub:

docker build -t fsouza/fake-gcs-server .