Last update: 2019-12-09

Making a Docker compose file for Guacamole


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:

<bash>
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'
services:
  mysql:
    image: mysql:latest
    restart: unless-stopped
    volumes:
      - type: bind
        source: "/storage/mysql"
        target: "/var/lib/mysql"
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: "changeme"
  guac:
    image: guacamole/guacd
    restart: unless-stopped
  guacamole:
    image: guacamole/guacamole
    restart: unless-stopped
    volumes:
      - type: bind
        source: "./index.jsp"
        target: "/usr/local/tomcat/webapps/ROOT/index.jsp"
    ports:
      - "8080:8080"
    environment:
      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:

<bash>
docker-compose down

Looking to expand into the cloud? See what a certified AWS administrator can do for you.


 
© 2007-2020 Patrick Lambert - All resources on this site are provided under the MIT License - You can contact me at: contact@dendory.net