The docker image expects some of the environment variables to be set to function properly. The following table lists all the environment variables available along with their usages.
Specifies the names of the keyspaces to be created as a comma separated value.
Specifies the number of shards in each keyspace. It is a comma separated value as well, read in conjunction with the KEYSPACES.
The starting of the port addresses that vitess will use to register its components like vtgate, etc.
Maximum number of connections that the MySQL instance will support. If unspecified, it defaults to 1000.
Which host to bind the MySQL listener to. If unspecified, it defaults to 127.0.0.1.
MySQL server version to advertise. If unspecified, it defaults to 8.0.31-vitess or 5.7.9-vitess according to the version of vttestserver run.
Default charset to use. If unspecified, it defaults to utf8mb4.
This is to provide how to handle foreign key constraint in create/alter table. Valid values are: allow (default), disallow.
Allow users to submit, review and control Online DDL. Valid values are: true (default), false.
Allow users to submit direct DDL statements. Valid values are: true (default), false.
Sets the default planner to use when the session has not changed it. Valid values are: Gen4 (default), v3, Gen4Greedy and Gen4Fallback. Gen4Fallback tries the new gen4 planner and falls back to the V3 planner if the gen4 fails.
Interval at which vtgate refreshes tablet information from topology server.
Environment variables in docker can be specified using the -e aka --env flag.
Sending queries to vttestserver container from outside #
The vtgate listens for MySQL connections on 3 + the PORT environment variable specified. i.e. if you specify PORT to be 33574, then vtgate will be listening to connections on 33577, on the MYSQL_BIND_HOST which defaults to localhost. But this port will be on the docker container side. To connect to vtgate externally from a MySQL client, you will need to publish that port as well and specify the MYSQL_BIND_HOST to 0.0.0.0. This can be done via the -p aka --publish flag to docker. For eg: adding -p 33577:33577 to the docker run command will publish the container's 33577 port to your local 33577 port, which can now be used to connect to the vtgate.
If you wish to keep the state of the test container across reboots, such as when running the vttestserver container as a database container in local application development environments, you may optionally pass the --persistent_mode flag, along with a --data_dir directory which is bound to a docker volume. Due to a bug, the --port argument must also be present for correct operation.
When running in this mode, underlying MySQL table schemas, their data, and the Vitess VSchema objects are persisted under the provided --data_dir.