Docker
Docker Image for Dolt CLI
Running this image is equivalent to running the dolt
command. You can get the latest version with latest
tag, or you can get a specific, older version by using the Dolt version you want as the image's tag (e.g. 0.50.8
).
Docker Image for Dolt SQL-Server
To check out supported options for dolt sql-server
, you can run the image with --help
flag.
Connect to the server in the container from the host system
To be able to connect to the server running in the container, we need to set up a port to connect to locally that maps to the port in the container. The host is set to 0.0.0.0
for accepting connections to any available network interface.
If we run the command above with -d or switch to a separate window we can connect with MySQL (empty password by default):
Define configuration for the server
Or, we can mount a local directory to specific directories in the container. The special directory for server configuration is /etc/dolt/servercfg.d/
. You can only have one .yaml
configuration file in this directory. If there are multiple, the default configuration will be used. If the location of configuration file was /Users/jennifer/docker/server/config.yaml
, this is how to use -v
flag which mounts /Users/jennifer/docker/server/
local directory to /etc/dolt/servercfg.d/
directory in the container.
The Dolt configuration and data directories can be configured similarly:
The dolt configuration directory is
/etc/dolt/doltcfg.d/
There should be one.json
dolt configuration file. It will replace the global dolt configuration file in the container.We set the location of where data to be stored to default location at
/var/lib/dolt/
in the container. The data directory does not need to be defined in server configuration for container, but to store the data on the host system, it can also be mounted to this default location.
There will be directory called /docker-entrypoint-initdb.d
inside the container, and all appropriate files including .sh
or .sql
files. They will be run after server has started. This is useful for such as setting up your database with importing data by providing SQL dump file.
Let's look at an example
Here is how I set up my directories to be mounted. I have three directories to mount in a directory called shared
,
databases
is empty and is used for storing my data,dolt
has a single.json
file that stores my dolt configurationserver
has a single.yaml
file that stores my server configuration
We can see both config files were used successfully.
We can verify that we have the data we create through the server in our local directory we mounted.
We can check for directory doltdb
created in our local /shared/databases
directory.
You can verify it has the data we created by using Dolt CLI Docker image if you do not have Dolt installed locally.
Server liveness and readiness checks
When running dolthub/dolt-sql-server
in an environment like Kubernetes, liveness and readiness checks can be configured with something like:
This above configuration uses the dolt
client within the server container to execute queries against the live server.
Last updated