TestRail can be installed via Docker containers, making it much easier to get up and running with TestRail. This includes all dependencies and files needed for TestRail keeping installation time to a minimum.
TestRail docker repository
TestRail docker zip package
You can also clone everything from the TestRail Docker Github Repo
Requirements
These requirements apply to any TestRail version from 9.4.1 through 10.3.1.
-
Install Docker + Docker-compose (on Linux, using
pipis recommended) - Some basic understanding of docker (e.g knowing what containers, images, detached mode, … are) → See the official Docker “Get Started” documentation
- Optional: If you’re using the
quickstart.shscript, also installsudoandip(usually pre-installed on most systems)
ℹ️ Important Note:
Starting with TestRail 9.5.1 Server, Cassandra is officially deprecated and enforcement is in place.
-
Admins must first run the Cassandra deprecation script in version 9.4.1 before upgrading to more recent versions.
-
If the script has not been executed, the upgrade to more recent versions will be blocked and a warning message will be displayed during the upgrade process.
👉 Please check our Cassandra Deprecation documentation.
Quick start with script
Follow these steps:
-
Run
quickstart.sh - Type in two passwords – one for the “normal” database user and one for root
- Wait a few moments – TestRail will be downloaded and set up
TestRail should be accessible via the following URL: http://localhost:8000
Finish the installation through the web UI (use the values printed by installer at the end).
Once inside the installation wizard, you must paste the following path for Chrome Headless Shell:
-
/usr/bin/chrome-headless-shell-linux64/chrome-headless-shell
Update Jira token configuration (Required for versions below 10.1.4)
If you are upgrading from a version earlier than 10.1.4, you must update the Jira token configuration file as part of this process.
- Download the update files here.
-
Update the files:
-
Locate the TestRail Server container name, for example
testrail-docker-srv -
Run the command below to copy the new
consts.phpfile into the container.docker cp patches/testrail-<version>/testrail/app/config/consts.php testrail-docker-srv:/var/www/testrail/app/config -
Set the correct file ownership.
docker exec -it testrail-docker-srv \ chown www-data:www-data /var/www/testrail/app/config/consts.php
-
Locate the TestRail Server container name, for example
Running TestRail using docker-compose
The compose file is configured via environment variables – it’s suggested to use a .env file. More about a .env file is available on the Docker env files documentation.
-
First, create a .env file with at least the mandatory variables for:
- DB_USER
- DB_NAME
- DB_PWD
- DB_ROOT_PWD
-
Next, run
docker-compose up(it will take a few minutes the very first time). - TestRail should be up! Access it via: http://localhost:8000
- Re-enter the values you specified in the .env file when the TestRail installer asks for the database settings.
-
To remove the instance, press Ctrl+C and
then
run
docker-compose down.
Environment variables
It’s suggested to create a local .env file, to specify user- or machine-specific variables (for more information, see the Docker env files documentation). The syntax is simple: e.g. ‘HTTP_PORT=8000’
Environment variables can also be set directly in the shell with the
same
syntax
and then using docker-compose.
- DB_PORT
- HTTP_PORT
- HTTPS_PORT
- DB_URL (e.g. http://internal.yourcompany.com/5.7.sql)
Pre-populated databases and TestRail’s config.php
Via the DB_URL variable, it’s also
possible
to provide a SQL-dump to be downloaded by the container, so TestRail
is already
pre-configured. For proper functionality, the config.php file
needs to be provided. Simply copy it into the _config folder.
Ensure that the values in the config.php file
match the database settings for user and password, which are specified
in
the
compose file for the db.
Using Compose files
General usage
docker-compose up
docker-compose down
The argument up starts the
container;
while down stops everything.
The docker-compose CLI
reference can be found here.
Additional useful options:
| Option | Description |
|---|---|
-v (remove named
volumes)
|
This is important to remove temporary volumes after shutdown and is recommended to be used. If the volumes should not be purged, don’t use this parameter. However, be aware that this might still cause some side effects. |
-f (file)
|
Can be used to specify a different compose file (by default docker-compose.yml is used) |
-p (project)
|
Required if multiple TestRail instances should be started.
Otherwise, docker-compose will
interact with an already running container.
|
The name of the folder docker-compose is started in (in this case, ‘internal-docker’) is used as a project name and is prepended to all spawned containers.
Recommendation: Use docker-compose down -v,
as it removes named and anonymous volumes!
General remarks on the compose files
- All compose files rely on additional volumes:
-
testrail_rootcontains the installation and gets mounted to/var/www/testrail -
testrail_optcontains uploaded files etc. and gets mounted to/opt/testrail -
testrail_dbcontains the database and gets mounted to/var/lib/mysql. -
testrail_configcontains the config.php file, which configures TestRail and is mounted to/var/www/testrail/config
Containers are connected though a testrail bridged
network. Start-order is important – php needs to be first, followed by
webserver
and DB.
Migrating & Upgrading TestRail
Running TestRail within Docker containers
Please have a look at the Readme in the Github repo.
TestRail uses docker-compose to run the individual services necessary and link the containers together.
To start/stop TestRail, these two commands do the job. Execute them in the root folder of the repo:
docker-compose up
docker-compose down
To start the containers in detached mode, just add a -d parameter: docker-compose up -d
The docker-compose files contain a number of variables with pre-assigned default values. To assign custom values for these variables, either create a .env file (as described on the docker env files documentation – it’s a simple text file with a VAR=VALUE syntax).
Otherwise, it’s also possible to provide the env-variables via command
line
like
export HTTP_PORT=8008 && docker-compose up -d.
The site linuxhint.com provides a good overview of how to use env-variables in bash.
Migrating from an existing TestRail Server installation to containers
Using a database within containers
If you’ve run a dedicated DB just for TestRail, it makes sense to also run the DB in a container. Follow these steps to upgrade:
-
Check the privileges of the mysql user before migrating. If a user
was
created
with ‘@localhost’ (restricting access to “from localhost only”),
you
need
to create a new user with sufficient right to allow remote connections:
-
Access the DB with
mysql -pand list all users + host:SELECT user, host FROM mysql.user; -
If the TestRail user has ‘localhost’ or some IP in the ‘host’
column
(and not ‘%’), a new user needs to be created – CREATE
USER
‘testraildocker’@’%’ IDENTIFIED BY ‘newpassword’; – >
GRANT ALL ON testrail.* TO 'testraildocker'@'%';
(The ‘%’ allows remote connections from any IP. If you know your docker subnet – usually 172.16.255.255 – use the respective internal docker subnet instead of ‘%’ for security hardening.)
-
Access the DB with
-
Copy the whole content of
/var/lib/mysqlto the_mysqlfolder and theconfig.phpfile to_config. -
If you want to keep attachments, reports, logs, and audit-logs, create
the
folders
logs, audit, reports, attachmentsin the_optfolder and copy the content from the old location to the newly created folders. -
Edit the
config.phpfile and change the ‘DB_HOSTNAME’ todb:3306. Also, change the LOG_PATH and the AUDIT_PATH to:define('LOG_PATH', '/opt/testrail/logs/'); define('AUDIT_PATH', '/opt/testrail/audit/'); -
If you’d like to use a specific port to access TestRail, create a
.env
file
(more here) and specify the port via
HTTP_PORT=<portNumber> -
Run
docker-compose up -d
Also change the paths for attachments and reports under TestRail > Administration > Site Settings to: /opt/testrail/attachments and /opt/testrail/reports
Using an external database
If you’re using an external database server, leave the DB server as it is and follow these steps:
-
Copy the
config.phpfile to_config. -
If you want to keep attachments, reports, logs, and audit logs, create
the
folders
logs,audit,reports, andattachmentsin the_opt folder, and copy the content from the old location to the newly created folders. -
Edit the LOG_PATH and the AUDIT_PATH in the config.php file to:
define('LOG_PATH', '/opt/testrail/logs/'); define('AUDIT_PATH', '/opt/testrail/audit/'); - If you’d like to use a specific port to access TestRail, create a .env file (more here) and specify the port via HTTP_PORT=<portNumber>
-
Run
docker-compose up -d
Also change the paths for attachments and reports under TestRail>Administration>Site Settings to: /opt/testrail/attachments and /opt/testrail/reports
Upgrading TestRail if you are already using containers
Option 1: Quick ‘n’ dirty
Simply use the upgrade script: upgradeTestRail.sh
This will upgrade TestRail if you stayed with the default configuration
created
by the quickstart script. Then you will need to follow these steps:
-
Locate the Apache docker container by running
docker ps -
Copy
CONTAINER IDfortestrail/apacheimage -
Run
docker exec -it <container_id>bash to enter docker container -
Navigate to
/var/www/testraildirectory -
Run
php run.php update
If you’re using custom locations for the DB-files, etc. use option 2, below.
Option 2: Doing the upgrade step-by-step
To upgrade TestRail from an older to a newer version (e.g. 6.0.0 to 6.0.1), perform the following steps:
-
Shut down the containers:
docker-compose down -v -
(Optional) If you’ve specified a dedicated TestRail version in e.g.
a
.envfile – set the version you want to upgrade to. -
Pull the images:
docker-compose pull - Recommended: Create backups (see below)
-
Start TestRail
docker-compose up -d -
Locate the Apache docker container by running
docker ps -
Copy
CONTAINER IDfortestrail/apacheimage -
Run
docker exec -it <container_id>bash to enter docker container -
Navigate to
/var/www/testraildirectory -
Run
php run.php update
Important
Create a backup of the folders containing the database and the folder
which
contains the logs, reports, attachments, and audits. By default,
these
folders
are _mysql and _opt in
the local directory. Also create a copy of the config.php files
located in _config.
You can also do a “safe” upgrade by copying these three folders to a
new
location
and then running docker-compose.
Advanced topics
Apache vs. nginx and MySQL vs. MariaDB
TestRail currently officially supports Apache + MySQL. Feel free to give nginx and mariadb a try – however, please note that this is not officially supported. For the case you find any issues with these two systems, please let us know, so we can get closer to a potential nginx/mariadb support in future.
Creating backups
All containers are stateless, so they can safely be removed. Relevant
data
is
stored in local volumes: by default in _config, _mysql,
and _opt. Just create a backup
of these
folders.
Environment variables
- TESTRAIL_VERSION
- OPT_PATH
- CONFIG_PATH
- MYSQL_PATH
- HTTP_PORT
- DB_PORT
- DB_URL
- DB_USER
- DB_PWD
- DB_NAME
- DB_ROOT_PWD
- TR_DEFAULT_TASK_EXECUTION
Building the images yourself
It’s also possible to build the Docker images by yourself. All Dockerfiles can be found in this folder. Build instructions are in the respective subfolders.