Provision OSticket with Docker
- Installation using Docker
- Customize
- Docker-Compose
- Build a customized OSTicket Image
- Backup & Restore
Update: The used Docker image in this tutorial is currently not compatible with the latest version of OSTicket (v1.17.3) => I recommend switching to this instead.
Installation using Docker
Pull osTicket Image from hub.docker.com:
docker pull osticket/osticket:latest
Make sure you have a MySQL container running that osTicket can use to store its data:
docker pull mariadb:latest
docker run --name osticket_mysql -d -e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_USER=osticket -e MYSQL_PASSWORD=secret -e MYSQL_DATABASE=osticket mariadb:latest
Now run this image and link the MySQL container:
docker run --name osticket -d --link osticket_mysql:mysql -p 8080:80 osticket/osticket
Wait for the setup process to finish - this will download the latest version of OSticket and might take a while:
docker logs osticket
Cloning into '.'...
Once installation is completed then browse to your osTicket staff control panel at http://localhost:8080/scp
. Login with default admin user & password:
- username:
ostadmin
- password:
Admin1
- password:
Customize
Adding Plugins
docker exec -ti osticket /bin/bash
All plugins can be found in the following directory. Use a volume mount to add community plugins:
ls -la /var/www/src/public/include/plugins
total 2908
drwxr-xr-x 14 www-data www-data 4096 Oct 17 09:07 .
drwxr-xr-x 12 www-data www-data 4096 Oct 17 09:06 ..
drwxr-xr-x 8 www-data www-data 4096 Oct 17 09:06 .git
-rw-r--r-- 1 www-data www-data 364 Oct 17 09:06 .gitignore
-rw-r--r-- 1 www-data www-data 0 Oct 17 09:06 .keep
-rw-r--r-- 1 www-data www-data 18026 Oct 17 09:06 LICENSE
-rw-r--r-- 1 www-data www-data 1023 Oct 17 09:06 README.md
drwxr-xr-x 3 www-data www-data 4096 Oct 17 09:06 audit
drwxr-xr-x 3 www-data www-data 4096 Oct 17 09:07 auth-2fa
drwxr-xr-x 3 www-data www-data 4096 Oct 17 09:07 auth-cas
drwxr-xr-x 3 www-data www-data 4096 Oct 17 09:07 auth-ldap
drwxr-xr-x 3 www-data www-data 4096 Oct 17 09:07 auth-oauth2
drwxr-xr-x 2 www-data www-data 4096 Oct 17 09:06 auth-passthru
drwxr-xr-x 2 www-data www-data 4096 Oct 17 09:06 auth-password-policy
-rw-r--r-- 1 www-data www-data 228 Oct 17 09:06 composer.json
-rw-r--r-- 1 www-data www-data 41176 Oct 17 09:07 composer.lock
-rw-r--r-- 1 www-data www-data 2808725 Oct 17 09:07 composer.phar
drwxr-xr-x 2 www-data www-data 4096 Oct 17 09:06 doc
drwxr-xr-x 15 www-data www-data 4096 Oct 17 09:07 lib
-rw-r--r-- 1 www-data www-data 24618 Oct 17 09:06 make.php
drwxr-xr-x 2 www-data www-data 4096 Oct 17 09:06 storage-fs
drwxr-xr-x 3 www-data www-data 4096 Oct 17 09:07 storage-s3
-rw-r--r-- 1 www-data www-data 1194 Oct 17 09:06 updates.pem
Install them from Manage/Plugins:
Language Packs
Download the language files and place them into:
ls -la /var/www/src/public/include/i18n/
total 44
drwxr-xr-x 4 www-data www-data 4096 Oct 17 10:14 .
drwxr-xr-x 12 www-data www-data 4096 Oct 17 10:14 ..
-rw-r--r-- 1 www-data www-data 1097 Oct 17 10:14 README.md
drwxr-xr-x 4 www-data www-data 4096 Oct 17 10:14 en_US
-rw-r--r-- 1 www-data www-data 20586 Oct 17 10:14 langs.php
drwxr-xr-x 3 www-data www-data 4096 Oct 17 10:14 vendor
by binding them into your container:
docker-compose.yml
volumes:
- type: bind
source: ./src/include/i18n/de.phar
target: /var/www/src/public/include/i18n/de.phar
read_only: true
And select them from the Admin panel:
Docker-Compose
version: '3.8'
services:
osticket-app:
image: osticket/osticket:latest
container_name: osticket
volumes:
- type: bind
source: ./src/include/i18n/de.phar
target: /var/www/src/public/include/i18n/de.phar
read_only: true
environment:
- CONTAINER_NAME=osticket
- MYSQL_USER=osticket
- MYSQL_HOST=osticket-db
- MYSQL_PASSWORD=secret
- MYSQL_DATABASE=osticket
ports:
- 8080:80
depends_on:
- osticket-db
networks:
- services
links:
- osticket-db
restart: unless-stopped
osticket-db:
image: mariadb:latest
container_name: osticket-db
volumes:
- /opt/osticket/db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=secret
- MYSQL_USER=osticket
- MYSQL_PASSWORD=secret
- MYSQL_DATABASE=osticket
- CONTAINER_NAME=osticket-db
networks:
- services
restart: unless-stopped
networks:
services:
external: false
Note: The volume mount
/opt/osticket/db:/var/lib/mysql
makes sure that all data written to MariaDB will be persisted. Make sure the host path/opt/osticket/db
exists and can be written to ~ or just change it to a dir that fulfills the requirement.
Build a customized OSTicket Image
The docker compose file contains a volume mount for the language file I added:
volumes:
- type: bind
source: ./src/include/i18n/de.phar
target: /var/www/src/public/include/i18n/de.phar
read_only: true
Actually, there are a lot more files that I need to mount - logos, styles and additional scripts. It makes sense for me to simply "bake" all of them into a customized image of OSTicket using the docker build
command.
Here I ran into a few issues with the official docker image and found this fork of it that is based on a PHP8 Alpine Linux image that is much more suitable for my task. You can build this image of OSTicket with:
docker build -t my/osticket .
Now we can use this image to add our customizations with a Dockerfile
FROM instar/osticket:latest
# add all your files here, e.g.
COPY ./src/include/staff/header.inc.php /var/www/html/include/staff/header.inc.php
#...
Now build this image and tag it according to your Docker Registry setup:
docker build -t my.gitlab.com:12345/server_management/my-osticket:latest .
When you pull this image you can still use the docker-compose.yml
file from above - but you no longer have to provide the volumen mounts and source files. Everything is baked in!
Backup & Restore
The database image uses a volume mount to persist all written data /opt/osticket/db:/var/lib/mysql
. You can use it to drop in an SQL dump to /opt/osticket/db
enter the MariaDB image:
docker exec -ti osticket-db /bin/bash
And restore your old OSTicket state:
Restore from MySQL Dump
mysql -uosticket -p osticket < Ticketsystem_2022-10-20.sql
Create a MySQL Dump
mysqldump -uosticket -p osticket > backup-file.sql
Enter password: secret