# Step 6 — Building an extension in Docker Step numbers in this file refer to the steps in `SKILL.md`. Only relevant if the user chose Docker and wants to build their own extension. This **replaces** the container from Step 2 rather than adding to it. Docker cannot add a mount to a running container, so remove the old one and create a new one with the source mounted. Remove the old container with `docker rm -f "$VSQL_CONTAINER"`. Then create the container again as in Step 2, and add `-v /path/to/my-extension:/src:ro` before the image name. The new container starts with an empty data directory, so the extension you installed in Step 5 is gone with the old one — redo that step here. If you know in advance that you will build an extension, add the `-v` mount in Step 2 and skip this replacement entirely. Wait for readiness again with the bounded loop from Step 3, then build: ```bash docker exec "$VSQL_CONTAINER" bash -c 'cp -r /src /work && vsql-build-extension.sh /work' ``` The image ships the SDK at `/usr/include/villagesql/`, its CMake package at `/usr/lib/cmake/VillageSQLExtensionFramework/`, a C++ toolchain, and that helper, which runs cmake and make, installs the resulting `.veb` into `veb_dir`, and waits for the server. Then `INSTALL EXTENSION` it as in Step 5. Mount read-only and copy to `/work` as shown. The helper builds into `/_docker_build`, which would otherwise write build output into your host checkout. ### Testing in the container Be precise about what is and is not available. `mysqltest` (the test executor) and `perl` are both in the image. What is missing is `mysql-test-run.pl`, the orchestrator that stages suites, substitutes `$MYSQLTEST_VARDIR`, manages workers, and starts and stops servers. So a single test file can be run by hand against the already-running server: ```bash docker exec "$VSQL_CONTAINER" mysqltest -u root \ --test-file=/work/mysql-test/t/.test \ --result-file=/work/mysql-test/r/.result ``` If the test file begins with `INSTALL EXTENSION`, run `UNINSTALL EXTENSION ;` first — the orchestrator normally provides the clean state that the file assumes, and without it the test fails with `already installed`. What you cannot do in this image is a normal `--suite=` run, anything relying on `$MYSQLTEST_VARDIR`, parallel workers, or multi-file suite management. For that, and for the `vsql-extension-builder` test phase, use an installer or source build.