Prisma servers can be run with Docker. This page contains everything you need to know around the Docker setup and relevant worfklows.
prisma Docker image is available via Docker Hub. You can pull the latest released version of the image using the following command:
docker pull prismagraphql/prisma
Here's a quick rundown of the most important commands:
docker-compose up -d: Start a new Prisma server to which you can deploy your Prisma services.
docker-compose stop: Stops the Prisma server.
docker-compose pull: Downloads the latest Prisma images from Docker Hub
docker logs: Shows the logs of the Prisma server (helpful for debugging).
Note that these commands need to be executed in the directory where the Docker Compose file for your Prisma server is available.
Here is an overview of all properties you need to configure on the
prisma Docker image inside your Docker Compose file. The all-uppercase words represent placeholders for the configuration variables you need to provide for your Prisma setup.
version: '3' services: prisma: image: prismagraphql/prisma:__LATEST_PRISMA_VERSION__ restart: always ports: - '4466:4466' environment: PRISMA_CONFIG: | managementApiSecret: __YOUR_MANAGEMENT_API_SECRET__ port: __YOUR_PRISMA_SERVER_PORT__ databases: default: connector: __YOUR_DATABASE_CONNECTOR__ migrations: __ENABLE_DB_MIGRATIONS__ host: __YOUR_DATABASE_HOST__ port: __YOUR_DATABASE_PORT__ user: __YOUR_DATABASE_USER__ password: __YOUR_DATABASE_PASSWORD__ connectionLimit: __YOUR_CONNECTION_LIMIT__
Most notably most of your configuration takes place in the
PRISMA_CONFIG environment variable.
Despite seemingly following the YAML key-value structure,
PRISMA_CONFIGis actually speficied as a string. The pipe character
PRISMA_CONFIGdenotes the beginning of a multi-line string in YAML.
These are the root properties of
|The Management API secret is used by the Prisma CLI to generate authentication tokens and authenticate its requests against the Prisma server. Example: |
|The port on which the Prisma server is running. Example: |
|Specifies to which databases the Prisma server should connect to.|
Each database object in the
databases object needs to include the following properties:
|Specifies which database connector to be used. Learn more.|
|Specifies if Prisma should be able to perform database migrations. Learn more.|
|The IP address or URL of the machine hosting the database. Example: |
|The post where the database is running.|
|The database name. Default: |
|The database user. Example: |
|The password for the database user specified in |
|The maximum number of database connections (must be at least 2). Learn more.|
To get insights into the internals of your Prisma server, you can check the logs of the Docker container.
View the raw logs from the running Docker containers:
Verify that the containers are running:
You should see an output similar to this:
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2b799c529e73 prismagraphql/prisma:1.25 "/bin/sh -c /app/sta…" 17 hours ago Up 7 hours 0.0.0.0:4466->4466/tcp myapp_prisma_1 757dfba212f7 mysql:5.7 "docker-entrypoint.s…" 17 hours ago Up 7 hours 3306/tcp prisma-db
This is helpful when you're getting an error message saying
Error response from daemon: No such container.
If your local Prisma server is in an unrecoverable state, it might be necessary to completely reset it:
docker-compose kill docker-compose down docker-compose up -d
Be careful as these commands will reset all data in your local Prisma server (including deployed Prisma APIs).