Docker
You can get a Dolt Docker container using our official Docker images. Both images support linux/amd64
and linux/arm64
platforms and updated on every release of Dolt. Older versions are also available, and tagged with the Dolt version they contain. The source of the Dockerfiles can be found here
Docker Image for Dolt CLI
The Dolt CLI Docker image is useful if you need a container that already has the Dolt CLI installed on it. For example, this image is a good fit if you are performing data analysis and want to work in a containerized environment, or if you are building an application that needs to invoke Dolt from the command line and also needs to run in a container.
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
The Dolt sql-server Docker image creates a container with dolt installed and starts a Dolt SQL server when running the container. It is similar to MySQL's Docker image. Running this image without any arguments is equivalent to running dolt sql-server --host 0.0.0.0 --port 3306
command locally, which is the default settings for the server in the container. The persisted host and port allows user to connect to the server from inside the container and from the local host system through port-mapping.
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
You can either define server configuration as command line arguments, or you can use yaml configuration file. For the command line argument definition you can simply define arguments at the end of the docker command. See the Dolt server configuration documentation for more details and available options.
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