Skip to content

Instantly share code, notes, and snippets.

@tbnorth
Last active February 20, 2021 19:44
Show Gist options
  • Save tbnorth/7552dd1ae922e278428ec653db7463d0 to your computer and use it in GitHub Desktop.
Save tbnorth/7552dd1ae922e278428ec653db7463d0 to your computer and use it in GitHub Desktop.
Set up Apache Guacamole using Docker

Apache Guacamole using Docker to put your personal desktop on the web

  • This guide doesn't cover security issues at all.
  • This guide is intended to just get your personal desktop onto the web so you can use it remotely, it doesn't cover serious multi-user Guacamole deployment.
  • At the end of this file there are some notes on installing docker, running a VNC server, and setting up a web proxy, but this guide really isn't meant to cover those topics.
  • This guide is based on Installing Guacamole with Docker from the Guacamole docs., but fills in all the bits they assumed.
  • This is only tested / developed for Ubuntu 18.04.
  • If Guacamole seems stuck in a login loop displaying the pink failed login popup - use Shift-Ctrl-Alt to get the Guacamole menu, then access Guacamole Settings from the pull down menu on the username, top right.

One time steps

These are steps to do once, you can just copy past them into the command line. First, wipe out any remnants of any previous run through these instructions:

docker kill some-guacd some-guacdb some-guacamole
docker rm some-guacd some-guacdb some-guacamole

This creates and runs a container called some-guacd running guacd

docker run --name some-guacd -d guacamole/guacd

Now a transient (--rm) run of the Guacamole container to get initial SQL commands, followed by adding the commands not included.

docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --postgres > initdb.sql
cat >> initdb.sql << EOT
CREATE USER guacamole_user WITH PASSWORD 'some_password';
GRANT SELECT,INSERT,UPDATE,DELETE ON ALL TABLES IN SCHEMA public TO guacamole_user;
GRANT SELECT,USAGE ON ALL SEQUENCES IN SCHEMA public TO guacamole_user;
EOT

Now create a Postgresql container and set up the DB on it

docker run -d --name some-guacdb library/postgres:10-alpine
docker cp initdb.sql some-guacdb:/guac_db.sql
sleep 3  # give it time to spin up
docker exec some-guacdb su postgres -c "createdb guacamole_db"
sleep 3  # give it time to create the DB
docker exec some-guacdb su postgres -c "psql -d guacamole_db -f /guac_db.sql"

Finally run the persistent version of the Guacamole container

docker run --name some-guacamole \
         -e POSTGRES_DATABASE=guacamole_db \
         -e POSTGRES_USER=guacamole_user \
         -e POSTGRES_PASSWORD=some_password \
         --link some-guacd:guacd \
         --link some-guacdb:postgres \
         -d \
         -p 8080:8080 \
         guacamole/guacamole
HOSTIP=$(docker exec some-guacamole bash -c "ip route | sed -n '/default/ {s/.*via //; s/ .*//; p}'")
echo "Use $HOSTIP to connect to VNC on HOST if host.docker.internal doesn't work"

At this point everything should be running and you should be able to access the Guacamole app. at http://127.0.0.1:8080/guacamole. Log in with the default admin. account, username and password both guacadmin unless you change them. Then create a connection to the VNC server on you local system.

  • Name can be anything you like
  • GUACAMOLE PROXY PARAMETERS (GUACD) - ignore these, this section mentions Hostname and Port, but these aren't the Hostname and Port you're looking for, look down to the next section...
  • Under PARAMETERS, specify Hostname, Port, and Password. Hostname will be the IP number printed at the end of the last command line above, something like 172.17.0.1. Port will probably be 5900 or 5910, depending on how you run the VNC server, and the password is whatever your VNC server password is.
  • scroll down to the bottom and Save the connection.

That's it - after a reboot you can start it all back up again with the single command

docker start some-guacd some-guacdb some-guacamole
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment