├── .env ├── Dockerfile ├── README.md └── docker-compose.yml /.env: -------------------------------------------------------------------------------- 1 | COMPOSE_PROJECT_NAME=guacamole 2 | MYSQL_ROOT_PASSWORD=P455w0rd 3 | MYSQL_DATABASE=guacamole_db 4 | MYSQL_USER=guacamole_user 5 | MYSQL_PASSWORD=Pass12345 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Guacamole database container using MySQL 2 | # 3 | # VERSION 0.1 4 | 5 | FROM mysql 6 | 7 | # Update these to stay in line with the official guacamole containers. 8 | ARG GUAC_REPO=glyptodon/guacamole-client 9 | ARG GUAC_VERSION=0.9.12-incubating 10 | 11 | # Fetch the needed schema files from the guacamole repo and place them where the 12 | # container will use them when initializing the server. 13 | ARG BASE_URL=https://raw.githubusercontent.com/${GUAC_REPO}/${GUAC_VERSION}/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/schema/ 14 | ADD ${BASE_URL}001-create-schema.sql /docker-entrypoint-initdb.d/ 15 | ADD ${BASE_URL}002-create-admin-user.sql /docker-entrypoint-initdb.d/ 16 | 17 | # Create a simple script that will run before the schema files and modify them 18 | # to use the database created by the MYSQL_DATABASE environment variable. 19 | RUN echo 'sed -i "1i USE $MYSQL_DATABASE;" /docker-entrypoint-initdb.d/*.sql' > /docker-entrypoint-initdb.d/000-use-database.sh 20 | 21 | # Change the permissions so everything can be modified and executed at runtime. 22 | RUN chmod 777 -R /docker-entrypoint-initdb.d/ 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # compose-guacamole 2 | 3 | [Guacamole](https://guacamole.incubator.apache.org/) is a really useful tool, 4 | but can be difficult to setup properly. The deployment process can be greatly 5 | simplified using docker containers, and orchestrated using `docker-compose`. 6 | 7 | This is a sample configuration for `docker-compose` that puts together all the components needed to deploy guacamole in a containerized environment. I merely fixed it and updated it to the newer official containers as of November 2017. 8 | 9 | This is currently version-pinned to `0.9.12-incubating`, since the database `Dockerfile` requires the client repository to be properly tagged to extract the database schema, and at the time of this writing there wasn't a newer tag. 10 | 11 | ## Usage 12 | 13 | Assuming you already have a working Docker installation and `docker-compose`, 14 | setup is really easy. 15 | 16 | ``` 17 | git clone git@github.com:BrowncoatShadow/compose-guacamole.git 18 | cd docker-compose-guacamole 19 | docker-compose up -d 20 | ``` 21 | 22 | Give it a few seconds to initialize and then you can access guacamole 23 | at `http://docker-host:8080/guacamole/`. The default username and password are 24 | both `guacadmin` (go to your user preferences to change it, and then create another user for regular use). 25 | 26 | You _definitely_ want to open the `.env` file and change the example database passwords 27 | before deploying this to anything resembling a production environment. 28 | 29 | ## Behind the Scenes 30 | 31 | `docker-compose` brings together several components to make this work. 32 | 33 | - `guacamole_data` - A persistent data volume that stores all the data even 34 | if the containers are destroyed. 35 | - `guacamole_db_1` - A MySQL container that acts as the database for all of 36 | guacamole's data. 37 | - `guacamole_guacd_1` - The guacamole server daemon (`guacd`) container that handles all the 38 | remote connections that guacamole makes. 39 | - `guacamole_guacamole_1` - The guacamole client web application container that ties 40 | everything together and provides the front-end for the user. 41 | 42 | 43 | ## The Database Problem 44 | 45 | Guacamole does not initialize its own database tables. Per the official 46 | documentation, the user is expected to create the database manually and use 47 | tools from the client container to generate the needed schema files to 48 | initialize the database tables. 49 | 50 | That is not very portable for a Docker container, which should be able to be 51 | created and destroyed on the fly. This is remedied in this project with a `Dockerfile` for the 52 | database container that fetches the needed schema files and uses environment 53 | variables to self-initialize. 54 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | db: 5 | hostname: db 6 | build: 7 | context: . 8 | restart: always 9 | volumes: 10 | - data:/var/lib/mysql 11 | environment: 12 | MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} 13 | MYSQL_DATABASE: ${MYSQL_DATABASE} 14 | MYSQL_USER: ${MYSQL_USER} 15 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 16 | 17 | guacd: 18 | hostname: guacd 19 | image: guacamole/guacd:0.9.12-incubating 20 | restart: always 21 | 22 | guacamole: 23 | image: guacamole/guacamole:0.9.12-incubating 24 | restart: always 25 | ports: 26 | - 8080:8080 27 | links: 28 | - guacd 29 | - db 30 | environment: 31 | GUACD_HOSTNAME: guacd 32 | MYSQL_HOSTNAME: db 33 | MYSQL_DATABASE: ${MYSQL_DATABASE} 34 | MYSQL_USER: ${MYSQL_USER} 35 | MYSQL_PASSWORD: ${MYSQL_PASSWORD} 36 | 37 | volumes: 38 | data: 39 | --------------------------------------------------------------------------------