Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save qupfer/a86d132e743b6af61c78637a5c9d34ee to your computer and use it in GitHub Desktop.
Save qupfer/a86d132e743b6af61c78637a5c9d34ee to your computer and use it in GitHub Desktop.

Create a pod to hold containers

podman pod create \
  --name YOUR_POD_NAME \
  -p 8080:8080

Create database initialization scripts

# the directory the database container will scan for initialization scripts
mkdir -p "guacamole-db/docker-entrypoint-initdb.d"

# files are scanned in order
# create the user and database first and initialize it next
# localhost doesn't work for the user with podman; must be 127.0.0.1
echo "CREATE USER 'YOUR_GUACAMOLE_USERNAME'@'127.0.0.1' IDENTIFIED BY 'YOUR_GUACAMOLE_PASSWORD';" > guacamole-db/docker-entrypoint-initdb.d/01_initdb.sql
echo "CREATE DATABASE YOUR_GUACAMOLE_DATABASE_NAME;" >> guacamole-db/docker-entrypoint-initdb.d/01_initdb.sql
echo "GRANT ALL PRIVILEGES ON YOUR_GUACAMOLE_DATABASE_NAME.* TO 'YOUR_GUACAMOLE_USERNAME'@'127.0.0.1';" >> guacamole-db/docker-entrypoint-initdb.d/01_initdb.sql
echo "USE YOUR_GUACAMOLE_DATABASE_NAME;" > guacamole-db/docker-entrypoint-initdb.d/02_initdb.sql
podman run --rm docker.io/guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql >> guacamole-db/docker-entrypoint-initdb.d/02_initdb.sql

Create the database

# the directory the database stores its data in
mkdir guacamole-db/data

podman run -d \
  --name=YOUR_DATABASE_CONTAINER_NAME \
  --pod=YOUR_POD_NAME \
  -e MARIADB_ROOT_PASSWORD=YOUR_DATABASE_ROOT_PASSWORD \
  -v $(pwd)/guacamole-db/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d \
  -v $(pwd)/guacamole-db/data:/var/lib/mysql \
  --restart unless-stopped \
  docker.io/mariadb:latest

Start guacd

podman run -d \
  --name=YOUR_GUACD_CONTAINER_NAME \
  --pod=YOUR_POD_NAME \
  --restart unless-stopped \
  docker.io/guacamole/guacd

Start guacamole

# must specify database and guacd params to connect within a pod
# must use 127.0.0.1, not localhost
podman run -d \
  --name=YOUR_GUACAMOLE_WEBAPP_CONTAINER_NAME \
  --pod=YOUR_POD_NAME \
  -e MYSQL_HOSTNAME=127.0.0.1 \
  -e MYSQL_PORT=3306 \
  -e MYSQL_DATABASE=YOUR_GUACAMOLE_DATABASE_NAME \
  -e MYSQL_USER=YOUR_GUACAMOLE_USERNAME \
  -e MYSQL_PASSWORD=YOUR_GUACAMOLE_PASSWORD \
  -e GUACD_HOSTNAME=127.0.0.1 \
  -e GUACD_PORT=4822 \
  --restart unless-stopped \
  docker.io/guacamole/guacamole
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment