Step by step
If you want to run OpenFGA locally as a Docker container, follow these steps:- Install Docker (if not already installed).
- Run
docker pull openfga/openfgato get the latest docker image. - Run
docker run -p 8080:8080 -p 8081:8081 -p 3000:3000 openfga/openfga run.
Using Postgres
- Docker
- Docker Compose
To run OpenFGA and Postgres in containers, you can create a new network to make communication between containers simpler:You can then start Postgres in the network you created above:You should now have Postgres running in a container in the Finally, start OpenFGA:
openfga network. However, it will not have the tables required for running OpenFGA. You can use the migrate command to create the tables. Using the OpenFGA container, this will look like:openfga migrate to configure the database and finally start the OpenFGA server.
Using MySQL
- Docker
- Docker Compose
We first make a network:Then, start MySQL in the network you created above:You should now have MySQL running in a container in the Finally, start OpenFGA:
openfga network. But we still have to migrate all the tables to be able to run OpenFGA. You can use the migrate command to create the tables. Using the OpenFGA container, this will look like:openfga migrate to configure the database and finally start the OpenFGA server.
Using SQLite
- Docker
- Docker Compose
We first make a network:Then, create a volume to hold the openfga database:Next you have to migrate all the tables to be able to run OpenFGA. You can use the Finally, start OpenFGA:
migrate command to create the tables. Using the OpenFGA container, this will look like:openfga volume to store the SQLite database, run openfga migrate to configure the database and finally start the OpenFGA server.
Pre-shared key authentication
To configure with pre-shared authentication and enabling TLS in http server with Docker.- Copy the certificate and key files to your Docker container.
- Run with the following command:
OIDC authentication
To configure with OIDC authentication and enabling TLS in http server with Docker.- Copy the certificate and key files to your docker container.
- Run the following command
Enabling profiling
If you are enabling profiling, make sure you enable the corresponding port in docker. The default port is3001, but if you need to serve the profiler on a different port, you can do so by specifying the --profiler-addr flag. For example:
Related sections
Check the following sections for more on how to use OpenFGA.Running OpenFGA in Production
Learn the best practices of running OpenFGA in a production environment