Docker

Run Chroma in a Docker Container#

You can run a Chroma server in a Docker container, and access it using the HttpClient.

If you are using Chroma in production, please fill out this form, and we will add you to a dedicated Slack workspace for supporting production users. We would love to help you think through the design of your system, or if you would be a good fit for our upcoming distributed cloud service.

If you are using a client in a separate container from the one running your Chroma server, you may only need the thin-client package

You can get the Chroma Docker image from Docker Hub, or from the Chroma GitHub Container Registry

Command Line

You can also build the Docker image yourself from the Dockerfile in the Chroma GitHub repository

Command Line

The Chroma client can then be configured to connect to the server running in the Docker container.

python

Authentication with Docker#

By default, the Docker image will run with no authentication. In client/server mode, Chroma supports the following authentication methods:

  • RFC 7617 Basic Auth with user:password base64-encoded Authorization header.
  • Static auth token in Authorization: Bearer <token> or in X-Chroma-Token: <token> headers.

You can learn more about authentication with Chroma in the Auth Guide.

Encrypted User:Password Authentication#

Server Set-Up#

Generate Server-Side Credentials#

To generate the password hash, run the following command:

Command Line

This creates the bcrypt password hash for the password admin, for the admin user, and puts it into server.htpasswd in your current working directory. It will look like admin:<password hash>.

Running the Server#

Create a .chroma_env file, and set in it the following environment variables:

text

Then, run the Chroma container, and pass it your .chroma_env using the --env-file flag:

Command Line

Client Set-Up#

In your client environment, set the CHROMA_CLIENT_AUTH_CREDENTIALS variable to the user:password combination (admin:admin in this example):

shell

Install python-dotenv. This will allow us to read the environment variables from .chroma_env easily:

shell

We will use Chroma's Settings object to define the authentication method on the client.

python

Static API Token Authentication#

Server Set-Up#

If, for example, you want the static API token to be "test-token", add the following environment variables to your .chroma_env. This will set Authorization: Bearer test-token as your authentication header.

text

If instead of the default Authorization: Bearer <token> header, you want to use a custom one like X-Chroma-Token: test-token, you can set the CHROMA_AUTH_TOKEN_TRANSPORT_HEADER environment variable:

text

Then, run the Chroma server:

Command Line

To configure multiple tokens and use them for role-based access control (RBAC), use a file like this and the following environment variables:

text

In this case, you will have to set up a volume to allow the Chroma Docker container to use your authz.yaml file:

Command Line

Client Set-Up#

Install python-dotenv. This will allow us to read the environment variables from .chroma_env easily:

shell

We will use Chroma's Settings object to define the authentication method on the client.

python

If you are using a custom CHROMA_AUTH_TOKEN_TRANSPORT_HEADER (like X-Chroma-Token), add it to your Settings:

python