How to run the server in Docker?
The agdb_server can be run in Docker using official Docker image. Optionally you can build the image yourself.
Install Docker
- Windows: https://www.docker.com/products/docker-desktop/
- Linux: https://docs.docker.com/desktop/setup/install/linux/
Pull or build the agdb_server image
The image is based on Alpine Linux using musl libc. The image is made available on Docker Hub or GitHub packages:
| Vendor | Tag | Command | Description |
|---|---|---|---|
| Docker Hub | latest | docker pull agnesoft/agdb:latest | Equals latest released version |
| Docker Hub | 0.x.x | docker pull agnesoft/agdb:0.x.x | Released version, e.g. 0.10.0 |
| Docker Hub | dev | docker pull agnesoft/agdb:dev | Equals latest development version on the main branch, refreshed with every commit to main |
| GitHub | latest | docker pull ghcr.io/agnesoft/agdb:latest | Equals latest released version |
| GitHub | 0.x.x | docker pull ghcr.io/agnesoft/agdb:0.x.x | Released version, e.g. 0.10.0 |
| GitHub | dev | docker pull ghcr.io/agnesoft/agdb:dev | Equals latest development version on the main branch, refreshed with every commit to main |
If you want to build the image yourself run the following in the root of the checked out agdb repository:
docker build --pull -t agnesoft/agdb:dev -f agdb_server/containerfile .Run the server
docker run -v agdb_data:/agdb/agdb_data --name agdb -p 3000:3000 agnesoft/agdb:devThis command runs the server using the default configuration (without TLS). It assigns a volume to the data directory for data persistence, gives the container a name (agdb) and publishes the container’s exposed port (3000) to the host. You can publish to a different local port (e.g. 5000:3000 (host:container)) where the container’s port 3000 will be locally accessible on the port 5000.
Test that the server is up with curl
curl -v localhost:3000/api/v1/status # should return 200 OKShutdown the server
The server can be shutdown either by stopping the container or programmatically posting to the shutdown endpoint as logged in server admin:
# this will produce an admin API token, e.g. "bb2fc207-90d1-45dd-8110-3247c4753cd5"
token=$(curl -X POST -H 'Content-Type: application/json' localhost:3000/api/v1/user/login -d '{"username":"admin","password":"admin"}')
curl -X POST -H "Authorization: Bearer ${token}" localhost:3000/api/v1/admin/shutdownTLS Support
In order to enable TLS support you need to provide following config values as per the server documentation:
tls_certificate: /agdb/cert.pem
tls_key: /agdb/cert.keyIf you are using self-signed certificate you should provide also the root CA via:
tls_root: /agdb/root_ca.pemYou can then mount the custom config and the certificates into the container as volume(s). Assuming the agdb_server.yaml and the certificates are in /local/path on your host machine:
docker run -v agdb_data:/agdb/agdb_data -v /local/path:/agdb --name agdb -p 3000:3000 agnesoft/agdb:devWhen you run the container this way it will load the configuration from /agdb/agdb_server.yaml and if it specifies the paths to the files they would be loaded as well.