Docker

Quickstart

Dolt can be run in Docker with a few short commands.
  1. 1.
    Install Dolt in your Dockerfile (refer below for complete sample Dockerfiles):
    1
    RUN curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
    Copied!
  2. 2.
    Build a dolt-test image:
    1
    > docker build -t dolt-test . -f Dockerfile
    Copied!
  3. 3.
    Run your image as an interactive container:
    1
    > docker run --rm -ti dolt-test /bin/bash
    Copied!
  4. 4.
    Verify Docker is installed and exit:
    1
    [[email protected] /]# dolt version
    2
    dolt version 0.24.4
    4
    exit
    5
    >
    Copied!

Dolt Run Command

Use entrypoints to set the default executable and params:
1
FROM centos
2
3
RUN yum install -y curl \
4
&& curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash \
5
&& dolt config --global --add user.name "FIRST LAST" \
6
&& dolt config --global --add user.email "[email protected]"
7
8
ENTRYPOINT ["dolt"]
9
CMD ["--help"]
Copied!
Used as follows:
1
> docker run dolt-test | head -n 5
2
Valid commands for dolt are
3
init - Create an empty Dolt data repository.
4
status - Show the working tree status.
5
add - Add table changes to the list of staged table changes.
6
reset - Remove table changes from the list of staged table changes.
7
> docker run dolt-test version
8
dolt version 0.24.4
Copied!
A more interesting example mounts a local data directory:
1
> mkdir test
2
> docker run -v $PWD/test:/home/test -w /home/test dolt-test init
3
Successfully initialized dolt data repository.
4
> docker run -v $PWD/test:/home/test -w /home/test dolt-test sql -q "create table t1 (a bigint primary key)"
5
> docker run -v $PWD/test:/home/test -w /home/test dolt-test sql -q "insert into t1 values (0), (1)"
6
Query OK, 2 rows affected
7
> docker run -v $PWD/test:/home/test -w /home/test dolt-test sql -q "select * from t1"
8
+---+
9
| a |
10
+---+
11
| 0 |
12
| 1 |
13
+---+
14
> ls test/.dolt
15
config.json* noms/ repo_state.json* temptf/ tmp/
Copied!

Dolt SQL-Server

A Dockerfile that runs Dolt in server mode by default might look like:
1
FROM centos
2
3
RUN yum install -y curl \
4
&& curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash \
5
&& dolt config --global --add user.name "FIRST LAST" \
6
&& dolt config --global --add user.email "[email protected]"
7
8
EXPOSE 3306
9
ENTRYPOINT ["dolt"]
10
CMD ["sql-server", "-l", "trace", "--host", "0.0.0.0"]
Copied!
If our current directory has a valid Dolt repo test:
1
> docker run -p 3306:3306 -v $PWD/test:/home/test -w /home/test dolt-test
2
Starting server with Config HP="0.0.0.0:3306"|U="root"|P=""|T="28800000"|R="false"|L="trace"
Copied!
If we run the command above with -d or switch to a separate window we can connect with MySQL (empty password by default):
1
> mysql> --user=root --host=0.0.0.0 -t test -p
2
mysql> select * from t1;
3
+------+
4
| a |
5
+------+
6
| 0 |
7
| 1 |
8
+------+
9
2 rows in set (0.01 sec)
Copied!

Docker-Compose SQL-Server

The Dockerfile from the SQL-Server example can be used in a docker-compose.yml:
1
version: '3.3'
2
services:
3
db:
4
build:
5
context: .
6
dockerfile: Dockerfile
7
restart: always
8
ports:
9
- '3306:3306'
10
expose:
11
- '3306'
12
volumes:
13
- ./test:/home/test
14
working_dir: /home/test
15
volumes:
16
test:
Copied!
Up'ing the resources exposes a server on port 3306, accessed with mysql as shown the last example.
1
> docker-compose up
2
Starting tmp_db_1 ... done
3
Attaching to tmp_db_1
4
db_1 | Starting server with Config HP="0.0.0.0:3306"|U="root"|P=""|T="28800000"|R="false"|L="trace"
5
db_1 | TRACE: received query select * from t1
6
db_1 | DEBUG: executing query
7
db_1 | TRACE: returning result row [INT64(0)]
8
db_1 | TRACE: returning result row [INT64(1)]
Copied!

Sample Dockerfiles

Ubuntu:
1
FROM ubuntu
2
3
RUN apt update \
4
&& apt update \
5
&& apt install -y curl \
6
&& curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
Copied!
Debian:
1
FROM debian
2
3
RUN apt update \
4
&& apt update \
5
&& apt install -y curl \
6
&& curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
Copied!
CentOS:
1
FROM centos
2
3
RUN yum install -y curl \
4
&& curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash
Copied!
Alpine:
1
FROM alpine
2
3
RUN apk add --no-cache bash curl \
4
&& curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash \
5
&& mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
Copied!
Last modified 7mo ago