> ## Documentation Index
> Fetch the complete documentation index at: https://tyk.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Install Developer Portal on Docker

> Installation guide for the Tyk Developer Portal on Docker

| Edition    | Deployment Type             |
| :--------- | :-------------------------- |
| Enterprise | Self-Managed, Hybrid, Cloud |

## Prerequisites

* [Docker](https://docs.docker.com/get-docker/)
* [Enterprise Edition License](/nightly/portal/overview/intro#getting-access)

<Note>
  Running on Podman, containerd, or another container runtime? See [Container Runtimes](/nightly/deployment-and-operations/container-runtimes).
</Note>

## Docker

This section explains how to install Tyk Developer Portal in a container using Docker.
Depending on your preferences, you can use MariaDB, MySQL or PostgreSQL for the database.

In this recipe, the database and the portal container will run on the same network, with the database storing its data on a volume. The portal's CMS assets (images, files and themes) are stored in the database, although this guide provides links to the documentation to use a persistent volume or an S3 bucket as a storage medium for CMS assets.
Additionally, all settings for the Portal are configured using an env-file.

<Warning>
  **Note**

  This document is just an example. Customize all fields, including the username, password, root password, database name and more.

  Be sure to update the connection DSN in the env-file accordingly.
</Warning>

### Using PostgreSQL

1. **Create a network for the portal deployment**

   To start with, you need to create a Docker network for communication between the database and the portal. Execute the following command to create it:

   ```console theme={null}
   docker network create tyk-portal
   ```

2. **Create an init script for PostgreSQL**

   To initialize a PostgreSQL database, you need to create an init script that will later be used to launch the PostgreSQL instance.
   Copy the content below to a file named `init.sql`, which you will need in the next step.

   ```sql theme={null}
   -- init.sql
   -- Creating user
   CREATE USER admin WITH ENCRYPTED PASSWORD 'secr3t';
   CREATE DATABASE portal;
   GRANT ALL PRIVILEGES ON DATABASE portal TO admin;
   ```

3. **Create the database volume and launch the database**

   The next step is to launch the PostgreSQL database for the portal. To achieve this, create a data volume for the database first:

   ```console theme={null}
   docker volume create tyk-portal-postgres-data
   ```

   Then launch the PostgreSQL instance by executing the following command:

   ```container theme={null}
   docker run \
   -d \
   --name tyk-portal-postgres \
   --restart on-failure:5 \
   -e POSTGRES_PASSWORD=secr3t \
   -e PGDATA=/var/lib/postgresql/data/pgdata \
   --mount type=volume,source=tyk-portal-postgres-data,target=/var/lib/postgresql/data/pgdata \
   --mount type=bind,src=$(pwd)/init.sql,dst=/docker-entrypoint-initdb.d/init.sql \
   --network tyk-portal \
   -p 5432:5432 \
   postgres:10-alpine
   ```

   **Note**

   <Warning>
     The above PostgreSQL configuration is an example. You can customize deployment of your PostgreSQL instance. Please refer to [the PostgreSQL documentation](https://www.postgresql.org/docs/current/installation.html) for further guidance.
   </Warning>

4. **Create an environment variables file**

   Creating an environment variables file to specify settings for the portal is the next step.
   This is optional, as you can alternatively specify all the variables using the -e option when starting your deployment.

   Here is an example of a sample environment file. For a comprehensive reference of environment variables, please refer to the [configuration section](/nightly/product-stack/tyk-enterprise-developer-portal/deploy/configuration) in the Tyk Developer Portal documentation.

   ```ini theme={null}
   PORTAL_HOSTPORT=3001
   PORTAL_DATABASE_DIALECT=postgres
   PORTAL_DATABASE_CONNECTIONSTRING=host=tyk-portal-postgres port=5432 dbname=portal user=admin password=secr3t sslmode=disable
   PORTAL_DATABASE_ENABLELOGS=false
   PORTAL_THEMING_THEME=default
   PORTAL_STORAGE=db
   PORTAL_LICENSEKEY=<your-license-here>
   ```

   Once you have completed this step, you are ready to launch the portal application with PostgreSQL in a Docker container.

5. **Pull and launch the portal container**

   To pull and launch the portal using Docker, use the command provided below.
   Ensure that you replace `<tag>` with the specific version of the portal you intend to launch before executing the command, e.g. `tykio/portal:v1.7` for the portal v1.7. You can browse all available versions on [Docker Hub](https://hub.docker.com/r/tykio/portal/tags) and in the [release notes section](/nightly/developer-support/release-notes/portal#1-7-0-release-notes).

   ```console theme={null}
   docker run -d \
       -p 3001:3001 \
       --env-file .env \
       --network tyk-portal \
       --name tyk-portal \
       tykio/portal:<tag>
   ```

   This command will launch the portal on localhost at port 3001. Now, you can bootstrap the portal and start managing your API products.

6. **Bootstrap the portal**

   Now the portal is running on port 3001, but it needs to be bootstrapped by providing credentials for the super admin user since it's the first time you are launching it.
   Follow the [bootstrapping section](/nightly/portal/install#bootstrapping-developer-portal) of the documentation to bootstrap the portal via the UI or the admin API.

7. **Clean up**

   If you want to clean up your environment or start the installation process from scratch, execute the following commands to stop and remove the portal container:

   ```console theme={null}
   docker stop tyk-portal
   docker rm tyk-portal
   docker stop tyk-portal-postgres
   docker rm tyk-portal-postgres
   docker volume rm tyk-portal-postgres-data
   ```

### Using MySQL

1. **Create a network for the portal deployment**

   To start with, you need to create a Docker network for communication between the database and the portal. Execute the following command to create it:

   ```console theme={null}
   docker network create tyk-portal
   ```

2. **Create the database volume and launch the database**

   The next step is to launch the MySQL database for the portal. To achieve this, create a data volume for the database first:

   ```console theme={null}
   docker volume create tyk-portal-mysql-data
   ```

   Then launch the MySQL instance by executing the following command:

   ```console theme={null}
   docker run \
   -d \
   --name tyk-portal-mysql \
   --restart on-failure:5 \
   -e MYSQL_ROOT_PASSWORD=sup3rsecr3t \
   -e MYSQL_DATABASE=portal \
   -e MYSQL_USER=admin \
   -e MYSQL_PASSWORD=secr3t \
   --mount type=volume,source=tyk-portal-mysql-data,target=/var/lib/mysql \
   --network tyk-portal \
   -p 3306:3306 \
   mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --sql-mode=ALLOW_INVALID_DATES
   ```

   <Warning>
     **Note**

     The above MySQL configuration is an example. You can customize deployment of your MySQL instance.

     Please refer to the [MySQL documentation](https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html) for further guidance.
   </Warning>

3. **Create an environment variables file**

   Creating an environment variables file to specify settings for the portal is the next step.
   This is optional, as you can alternatively specify all the variables using the -e option when starting your deployment.

   Here is an example of a sample environment file. For a comprehensive reference of environment variables, please refer to the [configuration](/nightly/product-stack/tyk-enterprise-developer-portal/deploy/configuration) section in the Tyk Developer Portal documentation.

   ```ini theme={null}
   MYSQL_ROOT_PASSWORD=sup3rsecr3t
   MYSQL_DATABASE=portal
   MYSQL_USER=admin
   MYSQL_PASSWORD=secr3t
   PORTAL_HOSTPORT=3001
   PORTAL_DATABASE_DIALECT=mysql
   PORTAL_DATABASE_CONNECTIONSTRING=admin:secr3t@tcp(tyk-portal-mysql:3306)/portal?charset=utf8mb4&parseTime=true
   PORTAL_DATABASE_ENABLELOGS=false
   PORTAL_THEMING_THEME=default
   PORTAL_STORAGE=db
   PORTAL_LICENSEKEY=<your-license-here>
   ```

   Once you have completed this step, you are ready to launch the portal application with MySQL in a Docker container or via Docker Compose.

4. **Pull and launch the portal container**

   To pull and launch the portal using Docker, use the command provided below.
   Ensure that you replace `<tag>` with the specific version of the portal you intend to launch before executing the command, e.g. `tykio/portal:v1.7` for the portal v1.7.
   You can browse all available versions on [Docker Hub](https://hub.docker.com/r/tykio/portal/tags) and in the [release notes](/nightly/developer-support/release-notes/portal#1-7-0-release-notes) section.

   ```console theme={null}
   docker run -d \
       -p 3001:3001 \
       --env-file .env \
       --network tyk-portal \
       --name tyk-portal \
       --mount type=bind,src=/tmp/portal/themes,dst=/opt/portal/themes \
       --mount type=bind,src=/tmp/portal/system,dst=/opt/portal/public/system \
       tykio/portal:<tag>
   ```

   This command will launch the portal on localhost at port 3001. Now, you can bootstrap the portal and start managing your API products.

5. **Bootstrap the portal**

   Now the portal is running on port 3001, but it needs to be bootstrapped by providing credentials for the super admin user since it's the first time you are launching it. Follow the [bootstrapping](/nightly/portal/install#bootstrapping-developer-portal) section of the documentation to bootstrap the portal via the UI or the admin API.

6. **Clean up**

   If you want to clean up your environment or start the installation process from scratch, execute the following commands to stop and remove the portal container:

   ```console theme={null}
   docker stop tyk-portal
   docker rm tyk-portal
   docker stop tyk-portal-mysql
   docker rm tyk-portal-mysql
   docker volume rm tyk-portal-mysql-data
   ```

## Docker Compose

This section provides a clear and concise, step-by-step recipe for launching the Tyk Developer Portal in a container using Docker Compose.
Depending on your preferences, you can use MariaDB, MySQL or PostgreSQL for the database.

In this recipe, the database and the portal containers will run on the same network, with the database storing it's data on a volume. The portal's CMS assets (images, files and themes) are stored in the database, although this guide provides links to the documentation to use a persistent volume or an S3 bucket as a storage medium for CMS assets.
Additionally, all settings for the Portal are configured using an env-file.

<Warning>
  **Note**

  This document is just an example. Customize all fields, including the username, password, root password, database name and more.
</Warning>

### Using PostgreSQL

1. **Create an init script for PostgreSQL**

   To initialize a PostgreSQL database, you need to create an init script that will later be used to launch the PostgreSQL instance.
   Copy the content below to a file named `init.sql`, which you will need in the next step.

   ```sql theme={null}
   -- init.sql
   -- Creating user
   CREATE USER admin WITH ENCRYPTED PASSWORD 'secr3t';
   CREATE DATABASE portal;
   GRANT ALL PRIVILEGES ON DATABASE portal TO admin;
   ```

2. **Create an environment variables file for configuring the portal and the database**

   Creating an environment file to specify settings for the portal is the next step.

   Here is an example of a sample environment file. For a comprehensive reference of environment variables, please refer to the [configuration section](/nightly/product-stack/tyk-enterprise-developer-portal/deploy/configuration) in the Tyk Developer Portal documentation.

   ```ini theme={null}
   PORTAL_HOSTPORT=3001
   PORTAL_DATABASE_DIALECT=postgres
   PORTAL_DATABASE_CONNECTIONSTRING=host=tyk-portal-postgres port=5432 dbname=portal user=admin password=secr3t sslmode=disable
   PORTAL_DATABASE_ENABLELOGS=false
   PORTAL_THEMING_THEME=default
   PORTAL_LICENSEKEY=<your-license-here>
   PORTAL_STORAGE=db
   ```

   Once you have completed this step, you are ready to launch the portal application with PostgreSQL via Docker Compose.

3. **Create a docker-compose file**

   Before launching the portal using docker-compose, you will need to create a `docker-compose.yaml` file. An example of the portal's docker-compose file is provided below, which you can use as a starting point and further customize to meet your specific requirements.

   Ensure that you replace `<tag>` with the specific version of the portal you intend to launch before executing the command, e.g. `tykio/portal:v1.7` for the portal v1.7. You can browse all available versions on [Docker Hub](https://hub.docker.com/r/tykio/portal/tags) and in the [release notes section](/nightly/developer-support/release-notes/portal#1-7-0-release-notes).

   ```yaml theme={null}
   version: '3.6'
   services:
   tyk-portal:
       depends_on:
       - tyk-portal-postgres
       image: tykio/portal:<tag>
       networks:
       - tyk-portal
       ports:
       - 3001:3001
       environment:
       - PORTAL_DATABASE_DIALECT=${PORTAL_DATABASE_DIALECT}
       - PORTAL_DATABASE_CONNECTIONSTRING=${PORTAL_DATABASE_CONNECTIONSTRING}
       - PORTAL_THEMING_THEME=${PORTAL_THEMING_THEME}
       - PORTAL_THEMING_PATH=${PORTAL_THEMING_PATH}
       - PORTAL_LICENSEKEY=${PORTAL_LICENSEKEY}
       - PORTAL_STORAGE=${PORTAL_STORAGE}

   tyk-portal-postgres:
       image: postgres:10-alpine
       volumes:
       - tyk-portal-postgres-data:/var/lib/postgresql/data/pgdata
       - ${PWD}/init.sql:/docker-entrypoint-initdb.d/init.sql
       networks:
       - tyk-portal
       environment:
       - POSTGRES_PASSWORD=secr3t
       - PGDATA=/var/lib/postgresql/data/pgdata

   volumes:
   tyk-portal-postgres-data:

   networks:
   tyk-portal:
   ```

4. **Pull and launch the portal container using docker-compose**

   To launch the portal using docker-compose, execute the command provided below.

   ```console theme={null}
   docker-compose --env-file .env up -d
   docker-compose --env-file .env up -d
   ```

   This command will launch the portal on localhost at port 3001. Now, you can bootstrap the portal and start managing your API products.

5. **Bootstrap the portal**

   Now the portal is running on port 3001, but it needs to be bootstrapped by providing credentials for the super admin user since it's the first time you are launching it. Follow the [bootstrapping section](/nightly/#bootstrapping-enterprise-developer-portal) of the documentation to bootstrap the portal via the UI or the admin API.

6. **Clean up**

   If you want to clean up your environment or start the installation process from scratch, execute the following commands to stop and remove the portal container:

   ```console theme={null}
   docker-compose down
   ```

### Using MySQL

1. **Create an environment variables file for configuring the portal and the database**

   The first step is to create an environment file to specify settings for the portal.

   Here is an example of a sample environment file. For a comprehensive reference of environment variables, please refer the [configuration section](/nightly/product-stack/tyk-enterprise-developer-portal/deploy/configuration) in the Tyk Developer Portal documentation.

   ```ini theme={null}
   MYSQL_ROOT_PASSWORD=sup3rsecr3t
   MYSQL_DATABASE=portal
   MYSQL_USER=admin
   MYSQL_PASSWORD=secr3t
   PORTAL_HOSTPORT=3001
   PORTAL_DATABASE_DIALECT=mysql
   PORTAL_DATABASE_CONNECTIONSTRING=admin:secr3t@tcp(tyk-portal-mysql:3306)/portal?charset=utf8mb4&parseTime=true
   PORTAL_DATABASE_ENABLELOGS=false
   PORTAL_THEMING_THEME=default
   PORTAL_STORAGE=db
   PORTAL_LICENSEKEY=<your-license-here>
   ```

   Once you have completed this step, you are ready to launch the portal application with MySQL via Docker Compose.

2. **Create a docker-compose file**

   Before launching the portal using docker-compose, you will need to create a `docker-compose.yaml` file.
   An example of the portal's docker-compose file is provided below, which you can use as a starting point and further customize to meet your specific requirements.

   Ensure that you replace `<tag>` with the specific version of the portal you intend to launch before executing the command, e.g. `tykio/portal:v1.7` for the portal v1.7.
   You can browse all available versions on [Docker Hub](https://hub.docker.com/r/tykio/portal/tags) and in the [release notes section](/nightly/developer-support/release-notes/portal#1-7-0-release-notes).

   ```yaml theme={null}
   version: '3.6'
   services:
   tyk-portal:
       depends_on:
       - tyk-portal-mysql
       image: tykio/portal:<tag>
       networks:
       - tyk-portal
       ports:
       - 3001:3001
       environment:
       - PORTAL_DATABASE_DIALECT=${PORTAL_DATABASE_DIALECT}
       - PORTAL_DATABASE_CONNECTIONSTRING=${PORTAL_DATABASE_CONNECTIONSTRING}
       - PORTAL_THEMING_THEME=${PORTAL_THEMING_THEME}
       - PORTAL_THEMING_PATH=${PORTAL_THEMING_PATH}
       - PORTAL_LICENSEKEY=${PORTAL_LICENSEKEY}
       - PORTAL_STORAGE=${PORTAL_STORAGE}

   tyk-portal-mysql:
       image: mysql:5.7
       command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
       volumes:
       - tyk-portal-mysql-data:/var/lib/mysql
       networks:
       - tyk-portal   
       environment:
       - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
       - MYSQL_DATABASE=${MYSQL_DATABASE}
       - MYSQL_USER=${MYSQL_USER}
       - MYSQL_PASSWORD=${MYSQL_PASSWORD}

   volumes:
   tyk-portal-mysql-data:

   networks:
   tyk-portal:
   ```

3. **Pull and launch the portal container using docker-compose**

   To launch the portal using docker-compose, execute the command provided below.

   ```console theme={null}
   docker-compose --env-file .env up -d
   docker-compose --env-file .env up -d
   ```

   This command will launch the portal on localhost at port 3001. Now, you can bootstrap the portal and start managing your API products.

4. **Bootstrap the portal**

   Now the portal is running on port 3001, but it needs to be bootstrapped by providing credentials for the super admin user since it's the first you are launching it. Follow the [bootstrapping section](/nightly/#bootstrapping-enterprise-developer-portal) of the documentation to bootstrap the portal via the UI or the admin API.

5. **Clean up**

   If you want to clean up your environment or start the installation process from scratch, execute the following commands to stop and remove the portal container:

   ```console theme={null}
   docker-compose down
   ```
