Tutorial: Run a test Docker image

Sometimes a developer wants to offer a “test” Docker image on the forum to allow users to test a new integration before it is deployed to production.

Unlike the “official” Docker image, which is hosted on the project account gladysassistant/gladys, a test image will be hosted on the developer’s Docker account. Example: jeanfrancois/gladys.

To run a test Docker image, it’s the same process as described on the Gladys installation page via Docker: Docker | Gladys Assistant.

The only difference is that you need to change the image name in the docker run to the test image, and modify some parameters of the command.

Before you begin

:warning: :warning: If you don’t know what you’re doing, avoid running your test image on the same machine as your production installation, as this could have consequences for your installation! :warning::warning:

Launching the test image

Let’s imagine we want to run a test image of the “zwave” integration, developed by “jeanfrancois”.

We’ll take the docker run command from the Gladys site, and modify several things:

  • The container name, for example « gladys-zwave-test » instead of « gladys »: --name gladys-zwave-test \\
  • The port on which Gladys runs, for example 8001 instead of 80: -e SERVER_PORT=8001 \\
  • The folder where all Gladys files will be stored (database, configuration): -v /var/lib/gladysassistant_zwave_test:/var/lib/gladysassistant \\
  • The name of the Docker image to run: jeanfrancois/gladys instead of gladysassistant/gladys

Which gives us this command :

docker run -d \
--log-driver json-file \
--log-opt max-size=10m \
--cgroupns=host \
--restart=always \
--privileged \
--network=host \
--name gladys-zwave-test \
-e NODE_ENV=production \
-e SERVER_PORT=8001 \
-e TZ=Europe/Paris \
-e SQLITE_FILE_PATH=/var/lib/gladysassistant/gladys-production.db \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /var/lib/gladysassistant_zwave_test:/var/lib/gladysassistant \
-v /dev:/dev \
-v /run/udev:/run/udev:ro \
jeanfrancois/gladys

To access Gladys:

http://IP_MACHINE:8001

To stop this container:

docker stop gladys-zwave-test

To remove this container:

docker rm gladys-zwave-test

To fetch a new version of the image

(if the dev has progressed on their integration):

docker pull jeanfrancois/gladys

Note that a Docker container is immutable: if you pull a new image, you must stop the container, remove the container, then docker run a new container :slight_smile:

Note:

Avoid connecting your Gladys Plus account to a test instance, as this will disconnect your production instance.

2 Likes