Skip to content

Install In Docker

Calin Crisan edited this page Mar 29, 2020 · 9 revisions

Why Docker?

Using docker probably the easiest way to try out qToggleServer without altering your system or installing otherwise unnecessary packages.

Another use case for a dockerized qToggleServer is when you already have other services running in Docker containers on your server and you want to add qToggleServer to your stack.

Try-out qToggleServer

On your Docker machine, simply run:

$ docker run -it --rm qtoggle/qtoggleserver:stable

Flags -it will start an interactive process on your terminal, while --rm will remove the container after you're done. You'll be able to observe the server log on your terminal. When you're done playing with it, just hit Ctrl+C.

Now point your browser to http://localhost:8888 and you should be presented with a login screen. Follow the Getting Started page for next steps. Keep in mind though that everything you do in this session is temporary and that your changes will be lost when you exit the container.

Production-ready Setup

If you want to run qToggleServer in a production environment, you'll have to:

  • supply your configuration instead of relying on defaults
  • use the appropriate persistence mechanism (database) so that your data is properly saved

Configuration File

Place your qtoggleserver.conf in your desired configuration folder. Then use -v when running your container to pass it as a volume accessible at /etc/qtoggleserver.conf:

$ docker run -v /path/to/qtoggleserver.conf:/etc/qtoggleserver.conf qtoggle/qtoggleserver:stable

Timezone

You can set the timezone of your container by passing the TZ environment variable using -e:

$ docker run -v /path/to/qtoggleserver.conf:/etc/qtoggleserver.conf \
             -e TZ=Europe/Berlin qtoggle/qtoggleserver:stable

JSON Data File

By default, qToggleServer uses a JSON file to save data that needs to be persisted. You'll need to use -v to pass it as a volume accessible at /qtoggleserver-data.json:

$ docker run -v /path/to/qtoggleserver.conf:/etc/qtoggleserver.conf \
             -v /path/to/qtoggleserver-data.json:/qtoggleserver-data.json \
             -e TZ=Europe/Berlin qtoggle/qtoggleserver:stable

For larger setups, Redis persistence driver is highly recommended.

Versions

Available versions correspond to Docker image tags. For example, if you want to run version 0.17.1 instead of the current stable version, use:

$ docker run -v /path/to/qtoggleserver.conf:/etc/qtoggleserver.conf \
             -v /path/to/qtoggleserver-data.json:/qtoggleserver-data.json \
             -e TZ=Europe/Berlin qtoggle/qtoggleserver:0.17.1

The stable tag always corresponds to the current (most recent) stable version, while latest represents the latest release, including beta versions.

Using docker-compose

Simple Example

A simpe docker-compose.yml file would look something like:

docker-compose.yml:
version: '3'
services:
  qtoggleserver:
    image: qtoggle/qtoggleserver:stable
    volumes:
      - /path/to/qtoggleserver.conf:/etc/qtoggleserver.conf
      - /path/to/qtoggleserver-data.json:/qtoggleserver-data.json
    environment:
      - TZ=Europe/Berling

Redis

Adding a redis service is usually a good idea. Make sure you have set the Redis persistence driver in your qtoggleserver.conf file and that the host driver parameter is set to redis.

Then you can add the redis service to your docker-compose.yml:

docker-compose.yml:
version: '3'
services:
  qtoggleserver:
    image: qtoggle/qtoggleserver:stable
    volumes:
      - /path/to/qtoggleserver.conf:/etc/qtoggleserver.conf
      - /path/to/qtoggleserver-data.json:/qtoggleserver-data.json
    environment:
      - TZ=Europe/Berlin
  redis:
    image: redis:alpine
    volumes:
      - /path/to/qtoggleserver-data:/data
Clone this wiki locally