context: .
ports:
- 8000:8000
env_file:
- .env
depends_on:
database:
condition: service_healthy
ollama-pull:
condition: service_completed_successfully
ollama-pull:
image: docker/genai:ollama-pull
env_file:
- .env
# ...
```
{{< /tab >}}
{{< tab name="Run Ollama outside of a container" >}}
To run Ollama outside of a container:
1. [Install](https://github.com/jmorganca/ollama) and run Ollama on your host
machine.
2. Update the `OLLAMA_BASE_URL` value in your `.env` file to
`http://host.docker.internal:11434`.
3. Pull the model to Ollama using the following command.
```console
$ ollama pull llama2
```
{{< /tab >}}
{{< tab name="Use OpenAI" >}}
> [!IMPORTANT]
>
> Using OpenAI requires an [OpenAI account](https://platform.openai.com/login). OpenAI is a third-party hosted service and charges may apply.
1. Update the `LLM` value in your `.env` file to
`gpt-3.5`.
2. Uncomment and update the `OPENAI_API_KEY` value in your `.env` file to
your [OpenAI API key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-api-key).
{{< /tab >}}
{{< /tabs >}}
## Run your GenAI application
At this point, you have the following services in your Compose file:
- Server service for your main GenAI application
- Database service to store vectors in a Neo4j database
- (optional) Ollama service to run the LLM
- (optional) Ollama-pull service to automatically pull the model for the Ollama
service
To run all the services, run the following command in your `docker-genai-sample`
directory:
```console
$ docker compose up --build
```
If your Compose file has the ollama-pull service, it may take several minutes for the ollama-pull service to pull the model. The ollama-pull service will continuously update the console with its status. After pulling the model, the ollama-pull service container will stop and you can access the application.
Once the application is running, open a browser and access the application at [http://localhost:8000](http://localhost:8000).
Upload a PDF file, for example the [Docker CLI Cheat Sheet](https://docs.docker.com/get-started/docker_cheatsheet.pdf), and ask a question about the PDF.
Depending on your system and the LLM service that you chose, it may take several
minutes to answer. If you are using Ollama and the performance isn't
acceptable, try using OpenAI.
## Summary
In this section, you learned how to set up a development environment to provide
access all the services that your GenAI application needs.
Related information:
- [Dockerfile reference](../../../reference/dockerfile.md)
- [Compose file reference](/reference/compose-file/_index.md)
- [Ollama Docker image](https://hub.docker.com/r/ollama/ollama)
- [Neo4j Official Docker Image](https://hub.docker.com/_/neo4j)
- [GenAI Stack demo applications](https://github.com/docker/genai-stack)
## Next steps
See samples of more GenAI applications in the [GenAI Stack demo applications](https://github.com/docker/genai-stack).