A straightforward way to run PocketBase using Docker and Docker Compose.
Make sure you have these installed:
- Docker: Installation Guide
- Docker Compose: Installation Guide (Often included with Docker Desktop)
-
Get Files: Save the
Dockerfileanddocker-compose.yamlinto a new empty directory on your computer. -
Navigate: Open your terminal or command prompt and
cdinto that directory:cd path/to/your/project-directory -
Build & Run: Execute the following command:
docker compose up -d --build
(This builds the image and starts the container in the background. The
--buildflag is only essential the first time or if you modify theDockerfile, but including it is safe.) -
Initial Admin Setup: Wait a few seconds for the container to initialize. Then, open your web browser to:
http://localhost:8080/_/Follow the on-screen instructions to create your first admin account (email/password). This setup step is only needed on the very first run when the data volume is empty.
- Admin UI:
http://localhost:8080/_/ - API Endpoint:
http://localhost:8080/(for your app interactions)
- Your PocketBase data (database files, uploaded assets, logs) is stored persistently in a Docker named volume called
pocketbase_data. - This volume is defined at the bottom of the
docker-compose.yamlfile.
Important: Your data will remain even if you stop and remove the container using
docker compose down. The volume is kept separately.
To stop and remove the PocketBase container (but keep the persistent data volume):
- Make sure you are in the same directory as your
docker-compose.yamlfile in your terminal. - Run the command:
docker compose down
To start the container again using your existing data:
- Navigate to the project directory in your terminal.
- Run:
docker compose up -d