Running inside Docker

Tutorial: CedarDB Docker Image

This tutorial explains how to build, configure and run the default CedarDB docker image.

Get the docker image

Interested in getting the Docker image? Join our waitlist and be among the first to get access to CedarDB!

Run the docker container

Run the container like so:

docker run -p 5432:5432 --name=cedardb_test cedardb

Configure the volumes correctly

You have to ensure that CedarDB stores its database on a reasonably fast SSD. To this end, the docker container defines a volume for persistency. This is mounted to a directory globally defined by docker by default. You can print this directory like so:

docker inspect cedardb_test | grep -A10 Mounts

Example result:


If this directory is on a fast SSD, you can skip this step. Otherwise, mount the volume at a better place, e.g.:

    docker run -p 5432:5432 -v /mnt/fastssd:/var/lib/cedardb/data --name=cedardb_test cedardb

Ensure that the docker user has write access for the directory you have chosen.

Create a database user

The docker image does not define a default and password for security reasons. You thus have to connect via domain socket from inside the docker container and create your own:

docker exec -it cedardb_test psql -h /tmp -U postgres

This will launch the psql shell. From within, you can then create a new user:

create user {{username}} superuser;
create database {{username}};
-- Set a password to connect from outside the container
alter user {{username}} with password '1234';

Connect to CedarDB from outside the container

From now on, you can connect from outside to the running CedarDB instance:

psql -h localhost -U {{username}}

Copy data into the container

In the following tutorials, we will often use the copy operator to load data into CedarDB, which requires the server to have access to the files. This way, the server can directly access the data without network overhead for more performant operations. Although \copy can be used to copy data relative to the psql client, we focus on copy (without \) in this tutorial for its higher performance. To access the data from the server, we first need to copy the downloaded data inside the docker container.

docker cp /your/path/download_folder cedardb_test:/var/lib/cedardb/data/

This command copies the folder download_folder to the CedarDB server, making it accessible without a path prefix.

Congratulations, you now have CedarDB running inside Docker and connect to it from the outside.