# Running GLPI on Docker

{% embed url="<https://www.youtube.com/watch?v=XhjlU2JzSQE>" %}

***

{% hint style="info" %}
**To get fast, reliable, and secure deployment with none of the work or hidden costs that come with self-hosting, check out** [**GLPI Network Cloud**](https://myaccount.glpi-network.cloud/register.php)
{% endhint %}

GLPI provides [an official Docker image and Stack via Dockerhub](https://hub.docker.com/r/glpi/glpi) that can be used for deployments on any system that runs Docker.

[If you need to report an issue.](https://github.com/glpi-project/glpi/issues/new?template=bug_report.yml)

## GLPI quick start

***

Use this quick start to run GLPI on its latest version locally. See below for instructions running GLPI in production Assuming you have Docker installed and running, get the latest Docker image:

In order to deploy the GLPI and MySQL Stack hereby, after you install Docker, two files are needed before pulling and running the image.

A [docker compose](https://github.com/docker/compose) yaml file and an `.env` file with environment variables used by the docker compose to correctly set up

* Database host
* Database host port
* GLPI Database name
* GLPI Database User
* GLPI Database Password

1. Choose the folder to storage these files
2. Create a file named `docker-compose.yml`
3. Paste the example Docker compose YAML file below
   1. Here's an example `docker-compose.yml` file for running a stack of the latest stable GLPI version on port `80` with MySQL instance named `db` and database named `glpi`on port `3306`
   2. [Volumes](https://outline.teclib.com/doc/running-glpi-on-docker-vlh9PkH3Lc#h-volumes) will be created on the same place where the docker compose is

```yaml
name: glpi
services:
  glpi:
    image: "glpi/glpi:latest"
    restart: "unless-stopped"
    volumes:
       # Using a named volume avoids permission issues on host (automatically managed by Docker)
       - glpi_data:/var/glpi
      # For GLPI 10.x, uncomment the following line to create a volume for plugins fetched from the marketplace.
      # - "./storage/glpi_marketplace:/var/www/glpi/marketplace/:rw"
    env_file: .env # Pass environment variables from .env file to the container
    depends_on:
      - db
    ports:
      - "80:80"

  db:
    image: "mysql"
    restart: "unless-stopped"
    volumes:
       - db_data:/var/lib/mysql
    environment:
      MYSQL_RANDOM_ROOT_PASSWORD: "yes"
      MYSQL_DATABASE: ${GLPI_DB_NAME}
      MYSQL_USER: ${GLPI_DB_USER}
      MYSQL_PASSWORD: ${GLPI_DB_PASSWORD}

volumes:
   glpi_data:
     - "./storage/glpi:/var/glpi:rw"
   db_data:
    - "./storage/mysql:/var/lib/mysql"
```

{% hint style="success" %}
It is possible to add **custom PHP configurations** if, for example, you want to increase the upload size, change the PHP memory limit, change the session cache expiry, etc.&#x20;

* **Create a file** (custom-config.ini for example) that will be loaded by PHP **with the options you wish to modify**
* Add an additional line to the **volume section** of your Docker configuration file so that your PHP file is loaded:&#x20;

**`- ‘/path/to/your/custom-config.ini:/usr/local/etc/php/conf.d/custom-config.ini:r’`**
{% endhint %}

4. Create a file named `.env`
5. Paste the env variables below

{% hint style="warning" %}
Change the values to your needs if needed.
{% endhint %}

```
GLPI_DB_HOST=db
GLPI_DB_PORT=3306
GLPI_DB_NAME=glpi
GLPI_DB_USER=glpi
GLPI_DB_PASSWORD=glpi
```

6. Run the composer

```sh
docker compose up -d
```

Once the containers are running, you can access GLPI at `http://localhost`.

{% hint style="success" %}
**GLPI will automatically install or update itself if needed.**
{% endhint %}

You can disable this behavior by setting the environment variables below to `true` in the `.env` file

* `GLPI_SKIP_AUTOINSTALL=true` – GLPI will not automatically install itself, and you need to run the wizard or console commands to install it manually
* `GLPI_SKIP_AUTOUPDATE=true` – GLPI will not automatically update itself, and you need to run the wizard or console commands to update it manually

{% hint style="info" %}
If you disable the automatic installation and update, you can use the credentials set in the env file, in order to set up the GLPI instance.
{% endhint %}

* `GLPI_DB_HOST` – Hostname
* `GLPI_DB_NAME` – Database
* `GLPI_DB_USER` – User
* `GLPI_DB_PASSWORD` – Password

### Find the Root MySQL Password

{% hint style="info" %}
Please note that we set up a random root password for the MySQL database, so you will need to check the logs of the `db` container to find it.
{% endhint %}

```sh
docker logs <db_container_id>
```

### Enable Timezones Support

If you want to initialize the [timezones support](https://glpi-install.readthedocs.io/en/latest/timezones.html) for GLPI, we need to first GRANT the glpi user access to `mysql.time_zone` table.

1. With the docker container running, run the following command:

```sql
docker exec -it <db_container_id> mysql -u root -p -e "GRANT SELECT ON mysql.time_zone_name TO 'glpi'@'%';FLUSH PRIVILEGES;"
```

{% hint style="info" %}
The root password will be the one you found in the logs of the `db` container previously.

Don't forget to change the `<db_container_id>` by the Database Container ID.
{% endhint %}

2. Run the following command to initialize the timezones on the GLPI container:

```sh
docker exec -it <glpi_container_id> /var/www/glpi/bin/console database:enable_timezones
```

{% hint style="info" %}
Don't forget to change the `<glpi_container_id_>` by the GLPI Container ID.
{% endhint %}

### Volumes

By default, the `glpi/glpi` image provides a volume containing its `config`, `marketplace` and `files` directories. For GLPI 10.0.x version, the marketplace directory is not declared in the volume as the path differs. You may want to create a manual volume for the path `/var/www/glpi/marketplace` if you plan to use it.

### Tags

In order for users to have different options for testing and deploying GLPI in different versions, even though the latest versions are always recommended, the GLPI Official Docker Composer allows you to choose between [different tags](https://hub.docker.com/r/glpi/glpi/tags) containing different versions of GLPI deployment.

GLPI Tags are in the docker compose file, on the line with the image name, where you may change to `image: "glpi/glpi:11.0.0-nightly"` to install GLPI 11 RC1 on Docker

See more tags here - <https://hub.docker.com/r/glpi/glpi/tags>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.glpi-project.org/tutorials/procedures/running_glpi_on_docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
