Here is how I setup for Guacamole running in Portainer. So, below is the compose file that I used.

services:
  guacdb:
    container_name: guacamoledb
    image: mariadb
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
      MYSQL_DATABASE: "guacamole_db"
      MYSQL_USER: "guacamole_user"
      MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
    volumes:
      - './db-data:/var/lib/mysql'
      - './db-schema:/opt/guac-schema'
  guacd:
    container_name: guacd
    image: guacamole/guacd
    restart: unless-stopped
  guacamole:
    container_name: guacamole
    image: guacamole/guacamole
    restart: unless-stopped
    ports:
      - 8080:8080
    environment:
      GUACD_HOSTNAME: "guacd"
      MYSQL_HOSTNAME: "guacdb"
      MYSQL_DATABASE: "guacamole_db"
      MYSQL_USER: "guacamole_user"
      MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
      TOTP_ENABLED: "true"
      WEBAPP_CONTEXT: "ROOT"
    volumes:
      - './db-schema:/opt/guac-schema'
    depends_on:
      - guacdb
      - guacd
volumes:
  db-data:
  db-schema:

First off I did not specify a specific version. In reality that should be done but for testing I wanted the latest. That is what this will bring back. Note: I used this post as inspiration. I also modified it to work with the latest MariaDB. So, simply put in the stack and then we will clean up things. Also note: this uses WEBAPP_CONTECT to get it on the root as opposed to on http://<server>:8080/guacamole. With out that WEBAPP it will have the */guacamole/ path. For simplicity I like it on the root.

Deploy the stack

Yes, that is correct we will run the create stack command and start up all the containers. Oh, do not forget to add env variables!

Those will be needed for all things to work correctly. In both pods guacamole and guacamoledb the are used to setup access to the MariaDB.

Once the variables are there it is time to create the stack!

What about DB schema?

We will get that all at the end. I just wanted to be able to bring up Guacamole in Portainer and then use it to get what is needed and so this way it is as seemless for Portainer as possible. This is where the only moutpoint in the guacamole container comes in to play.

volumes:
- './db-schema:/opt/guac-schema'

That creates a link between the MariaDB container and guacamole so the dbschema.sql can be dumped out directly to the same volume mariadb is using so now I can run a command on guac container and it will generate a sql file for the db to create needed db in mariadb.

Execute bash On Guacamole Container.

So, now it is time to execute the command on guacamole container needed to create schema so it can be used by Mariadb.

Run Bash as ROOT

As noted in above image caption execute bash as root user on guacamole container. It is important that the user is set to root so that it is possible to save to the volume mount /opt/guac-schema

/opt/guacamole/bin/initdb.sh --mysql > /opt/guac-schema/schema.sql

That’s it, you can now disconnect from the pod and head on over to the mysql pod and run the sql into the guacamoledb container by executing bash on it. You do not need to run as root on this container unless you want to do so. It is not required to read from the schema.sql created earlier.

mariadb --password=${MYSQL_ROOT_PASSWORD} --user=root guacamole_db < /opt/guac-schema/schema.sql

All done exec the guacamoledb conainer. Finally, restart the guacamole container to clean up the failed first run. Should be able to login with user: guacadmin password: guacadmin. Yes, please change the password at the very least on first login!!!

Leave a Reply

Your email address will not be published. Required fields are marked *