CLIdock db

dock db

Manage databases from the CLI.

Plain English A database stores your app’s data. dock db lets you create one, see its credentials, connect it to an app, inspect logs, run SQL, and create backups.

What dock db --help shows

dock db lsList your databases.
dock db info [db]Show engine, status, host, port, username, password, and public address if enabled.
dock db create [name]Create a database. Use —type and optional —version.
dock db rm [db]Delete a database after confirmation. This deletes data.
dock db connection [db]Print the connection string your app or tool can use.
dock db logs [db]Show recent logs from the database container.
dock db sql [db]Open an interactive query prompt.
dock db shell [db] [command]Run a shell command inside the database container.
dock db link <db> [project]Connect a database to an app project. The app gets DB variables on next deploy.
dock db unlink [project]Remove the app’s linked database.
dock db start [db]Start a stopped database.
dock db stop [db]Stop a running database.
dock db restart [db]Restart the database container.
dock db backups ls [db]List backups for a database.
dock db backups create [db]Create a backup now.

Create a database

dock db create production --type postgres --version 16

Supported --type values:

  • postgres
  • mysql
  • mariadb
  • mongodb
  • redis
  • valkey
  • clickhouse

If you omit --version, DockHosting uses the default version for that engine.

dock db link production my-app
dock deploy

Linking means DockHosting gives the app database connection variables on the next deploy. Your app still has to read those variables and connect.

Redeploy after linking Linking changes the app’s environment. The current running container will not automatically receive the new variables until you redeploy or restart in the correct flow.

Backups

dock db backups ls production
dock db backups create production

Backups are created in the background. Check the backup list for status.

Interactive access

dock db sql production
dock db shell production "ls /"

Use sql for database queries and shell for commands inside the database container.

Be careful in shells and SQL prompts Commands here can change or delete real data. Create a backup before risky changes.