Skip to main content

Making a Docker compose file for Guacamole

turned on MacBook Pro beside gray mug

I recently had a need to run Apache Guacamole, which is a web based interface to SSH and RDP sessions, allowing you to connect to servers remotely with just a web browser. Since Guacamole is fairly heavy and has dependencies on things like Tomcat and MySQL, I decided to run it as a Docker container. There are many good tutorials online such as this one that I initially followed, but soon ran into an issue. Basically, to run Guacamole you have to run 3 separate containers with specific run command arguments. So I decided to convert the manual instructions into a docker-compose file.

Docker compose is a command line interface that allows you to group containers together, along with their build and run instructions (such as which ports to map, which volumes to mount, etc) in a single YAML file called docker-compose.yml. This allows the configuration options to be saved, and then you can start all the related containers with a single command:

docker-compose up -d

One thing to note is that you may need to create the Guacamole database and run this SQL query first in the MySQL database if this is the first time you’re trying to install Guacamole. Also, I created an empty file at index.jsp which replaces the default Tomcat landing page. Finally, I have an empty folder at /storage/mysql to retain the database.

Here is my docker-compose.yml file:

version: '3.2'
    image: mysql:latest
    restart: unless-stopped
      - type: bind
        source: "/storage/mysql"
        target: "/var/lib/mysql"
      - "3306:3306"
      MYSQL_ROOT_PASSWORD: "changeme"
    image: guacamole/guacd
    restart: unless-stopped
    image: guacamole/guacamole
    restart: unless-stopped
      - type: bind
        source: "./index.jsp"
        target: "/usr/local/tomcat/webapps/ROOT/index.jsp"
      - "8080:8080"
      GUACD_HOSTNAME: "guac"
      MYSQL_DATABASE: "guacamole"
      MYSQL_USER: "guacamole"
      MYSQL_PASSWORD: "changeme"
      MYSQL_HOSTNAME: "mysql"
      MYSQL_PORT: 3306

By using the docker-compose command, you can start all 3 containers at once, mapping the environment variables, ports and volumes. This allows the MySQL and Guacamole ports to be exposed on the local host, the database to be saved, and the containers to link together thanks to the various settings. Assuming everything starts up properly, the Guacamole interface should be available at http://localhost:8080

To shut down the containers, simply run:

docker-compose down