---
updatedAt: 2025-09-22T20:32:02.000Z
agentTools:
  projectIndex: https://docs.v7labs.com/llms.txt
---

# Using the darwin-py Dockerfile

This guide will walk you through the steps required to build and run `darwin-py` as a Docker container. The `darwin-py` package provides a Python SDK and CLI to interact with the V7 Darwin platform, and this Dockerfile helps you set up a consistent environment for its use.

## Prerequisites

Before you begin, ensure you have the following installed on your system:

* [Docker](https://www.docker.com/) (Docker Engine)
* [Docker Compose](https://docs.docker.com/compose/) (optional, for complex multi-container setups)

### 1. Obtain the Dockerfile

You can find the Dockerfile in the `darwin-py` repository from versions 1.0.4 onward. Clone the repository or download the Dockerfile to your working directory:

```shell shell
git clone https://github.com/v7labs/darwin-py.git
cd darwin-py
```

Ensure the Dockerfile is located in your working directory:

```shell
ls
Dockerfile  pyproject.toml  poetry.lock  ...
```

### 2. Build the Docker Image

To build the Docker image, open a terminal in the directory containing the Dockerfile and run the following command:

```shell
docker build -t darwin-py .
```

* `-t darwin-py`: This tags the image with the name darwin-py, making it easier to reference later

The build process will:

* Install necessary build tools
* Install Python dependencies using [Poetry](https://python-poetry.org/)
* Install the darwin-py package and CLI

### 3. Customise the Dockerfile

If you have specific requirements, you can customise the Dockerfile before building:

* Copy across files: Uncomment and modify the `COPY . /app` line to include any local files you might need, such as files to upload to datasets, annotations to import, or credentials for [authenticating](https://docs.v7labs.com/docs/create-a-dataset-using-the-darwin-python-library-1)
* Expose Ports: Uncomment and modify the `EXPOSE` line to expose any necessary ports

### 4. Authenticate

Almost all darwin-py functionality requires that you are authenticated with a particular Darwin team you wish to interact with. You can authenticate by:

* Creating a client directly from an API key:

```python Python
from darwin.client import Client

API_KEY = "YOUR_API_KEY_HERE"
client = Client.from_api_key(API_KEY)
```

* From your `~/.darwin/config.yaml`file. If you've used `darwin-py` before, you can copy across your config file to the container:

```python
from darwin.client import Client

client = Client.local(team_slug='team_slug')
```

* Via the CLI command, `darwin authenticate`:

```shell
>darwin authenticate
API key: 
Make {team_slug} the default team? [y/N] y
Datasets directory [~/.darwin/datasets]: 
Authentication succeeded.
```