Getting Started with Container Apps

Container Apps allows you to launch and run a container from directly within Postgres. Container Apps is currently in public beta on Crunchy Bridge. During public beta you may find issues and areas of possible improvement, we welcome you sharing all feedback with us as we progress towards making it generally available.

Getting started with Container Apps in Postgres

Container Apps is powered by a Crunchy Data extension pgpodman. You can setup your database with the extension by running:

CREATE EXTENSION pgpodman;

Once you’ve setup the extension you can launch your first container. Below you’ll find an example for launching pgAdmin4 directly from within Postgres:

SELECT run_container('-dt -p 5433:80/tcp -e PGADMIN_DEFAULT_EMAIL="[email protected]" -e PGADMIN_DEFAULT_PASSWORD="myVeryGoodPassword" -e PGADMIN_LISTEN_PORT=80 docker.io/dpage/pgadmin4');

The above command has a few key pieces. The first is -p which will expose the docker image to the public port (the first of the two 5433 values), and route it to the port the docker image is listening on in this case port 80. Then we export all of the relevant environment variables to start up the container:

  • PGADMIN_DEFAULT_EMAIL is the default email for the initial account in pgAdmin4
  • PGADMIN_DEFAULT_PASSWORD is the default password for the initial account in pgAdmin4
  • PGADMIN_LISTEN_PORT is the port which the pgAdmin4 web application will start up on. This needs to match the second port in our earlier config.

And the final value is the specific docker image you want to launch. Once you’ve run the above you can now visit your pgAdmin4 app, which will be running on the hostname of your connection string at port 5433 - http://p.o7kabmt4wndjnp46exmkhvn634.db.postgresbridge.com:5433.

Common use cases for Container Apps with Postgres

We see three common use cases for Container Apps with Postgres on Crunchy Bridge:

  1. Turn key apps on top of Postgres databases (examples include pg_tileserv, postgraphile, PostgREST)
  2. Data reporting and visualization apps on top of your data (examples include pgAdmin4, Blazer)
  3. Running database monitoring agents right along side your instance (examples include DataDog, New Relic, pganalyze)

For many of the above we have a collection of recipes to help get you up and running with examples, but you’re not limited to just the examples above. Any public docker image can be run, if you feel some are particular great for Container Apps on Crunchy Bridge please reach out and we can explore adding it to our examples.

More with pgpodman

The pgpodman extension has a few other pieces included to help when working with Container Apps on Crunchy Bridge. The functions supported with pgpodman include:

  • SELECT run_container(<podman_options>) - Start a container within your database.
  • SELECT list_containers(show_all boolean) - List all containers and status. By default assumes a false flag. With show_all parameter as false it will list only running containers, true will list all containers both running and stopped.
  • SELECT list_containers_json(show_all boolean) - JSON-formatted output of list_containers().
  • SELECT stop_container(<container_id>) - Stop a running container, but leaves it on the filesystem.
  • SELECT start_container(<container_id>) - Starts a container that is currently in a stopped state.
  • SELECT container_status(<container_id>) - Show status of a container.
  • SELECT container_logs(<container_id>) - Show the logs from a container.
  • SELECT remove_container(<container_id>) - Remove a stopped container from the container list.
  • SELECT is_container_running(<container_id>) - Returns true if the given container is currently running.
  • SELECT list_images() - List all currently downloaded images.
  • SELECT list_images_json() - JSON-formatted output of list_images().
  • SELECT pull_image(<image_name>) - Downloads, but does not run, the indicated image.
  • SELECT remove_image(<image_id>) - Deletes the image from the local image cache.
  • SELECT pgpodman_version() - Returns a version string with the currently loaded extension library (pgpodman.so) version number, and the version of the podman executable program.

Available ports

Currently Container Apps within Crunchy Bridge exposes 10 ports to you to launch containers on during the public beta. Ports 5433 to 5442 are available to be exposed to the public internet.

Limits

Currently the filesystem is restricted to 2 GB of containers. In order effectively manage the size of containers we recommend remove_container to free up space after stopping a container.

Samples

There are a number of examples we’ve provided within our docs to help you get started. If an example app you’re looking for isn’t here you can feel free to still run it yourself, and if you’d need help in the form of a quickstart let us know which app and well aim to get it documented.

Database Admin and Browser Apps

Turnkey APIs and Apps

Database monitoring tools