Using the YDB Docker container
For debugging or tests, you can create a local Yandex Database instance in a Docker container. Docker containers use the current YDB build version, but the build revision may differ.
When a local database is running, some tasks may require a significant portion of a machine's resources.
Downloading a YDB Docker image
Download a Docker image by running the command:
sudo docker pull cr.yandex/yc/yandex-docker-local-ydb:latest
cr.yandex/yc/yandex-docker-local-ydb:latest: Current version of a Docker image.
Make sure the Docker image has downloaded:
docker image list
Running the YDB Docker container
In local launch mode, you can only interact with a database using the API.
The data handling API deploys to port
2135, and the previously created database is called
Yandex Database in a Docker container accepts incoming TLS-encrypted connections. To establish a connection, automatically generated certificates are used.
For certificates to work correctly, you must mount the following directory from a running Docker container:
To save the database state in a local directory, use the following directory from inside the Docker container:
To start the YDB Docker container and mount the required directories, run the command:
docker run --name ydb-local --rm --hostname localhost --rm -dp 2135:2135 -dp 8765:8765 -v $(pwd)/ydb_certs:/ydb_certs -v $(pwd)/ydb_data:/ydb_data -e YDB_LOCAL_SURVIVE_RESTART=true cr.yandex/yc/yandex-docker-local-ydb:latest
--name: Docker container name.
--hostname: Container hostname.
It can take up to two minutes to initialize a Docker container, depending on how powerful your computer is. The database will not be available until the container is initialized.
Like Yandex Database, Yandex.Cloud uses a secure TLS connection to exchange data with the local database.
To work with Yandex Database in a Docker container, use the certificate located in the
/ydb_cert directory mounted from a running Docker container.
ydb -e grpcs://localhost:2135 --ca-file $(pwd)/ydb_certs/ca.pem -d /local table query execute -q 'select 1;'
--ca-file: Option used to set the path to the TLS certificate.
┌─────────┐ | column0 | ├─────────┤ | 1 | └─────────┘
Stopping a Docker container
Once your work is complete, you can stop a Docker container with the command:
docker kill ydb-local
YDB Docker containers support several additional options accessible through environment variables:
YDB_LOCAL_SURVIVE_RESTART=true: Enables you to restart a container without losing data.
YDB_USE_IN_MEMORY_PDISKS=true: Enables you to store all your data in memory. If this option is enabled, restarting the container with a local YDB instance will result in complete data loss.
YDB_DEFAULT_LOG_LEVEL=<level>: Enables you to configure the default logging level. Valid levels:
License and components
The Docker container root includes a file with the license agreement (
LICENSE) and a list of the components used and their licenses (
Display the license agreement by running the command:
sudo docker run --rm -it --entrypoint cat cr.yandex/yc/yandex-docker-local-ydb LICENSE
View all the included components and their licenses:
sudo docker run --rm -it --entrypoint cat cr.yandex/yc/yandex-docker-local-ydb THIRD_PARTY_LICENSES