Skip to content

Instantly share code, notes, and snippets.

@timaschew
Created September 20, 2025 21:24
Show Gist options
  • Select an option

  • Save timaschew/bd9820d6f284a917758907addfb6f67d to your computer and use it in GitHub Desktop.

Select an option

Save timaschew/bd9820d6f284a917758907addfb6f67d to your computer and use it in GitHub Desktop.
Dokku - Attach existing app (managed via docker-compose for example)
#!/bin/bash
# script from https://dokku.com/docs/networking/network/#routing-an-app-to-a-known-ipport-combination
# for a service listening on:
# - ip address: 127.0.0.1
# - port: $port
DOMAIN=yourdomain.com
read -p "App name: " app
read -p "port: " port
read -p "subdomain: " subdomain
echo "binding dokku app '$app' from 127.0.0.1:$port to $subdomain.$DOMAIN"
read -n 1 -p "Please verify and press enter" verify
# create the app
dokku apps:create $app
# add an extra host that maps host.docker.internal to the docker gateway
dokku docker-options:add $app deploy "--add-host=host.docker.internal:host-gateway"
# set the SERVICE_HOST to the mapped hostname
dokku config:set $app SERVICE_HOST=host.docker.internal
# set the SERVICE_PORT to the port combination for your app
dokku config:set $app SERVICE_PORT=$port
# set the domains desired
dokku domains:set $app $subdomain.$DOMAIN
# deploy the service-proxy image
dokku git:from-image $app dokku/service-proxy:latest
echo "please run: dokku letsencrypt:enable $app"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment