Skip to content

MyVector Docker Images

Location

https://github.com/askdba/myvector/pkgs/container/myvector

The MyVector Docker images are published to the GitHub Container Registry (see the link above). They are built on top of community MySQL Docker images from:

https://hub.docker.com/r/mysql/mysql-server/

What is in the docker image?

This depends on the image tag's install mechanism (see the Versions table for which tag is which):

Plugin images (mysql8.0, mysql8.4, mysql9.7, latest) — pre-built MyVector plugin (myvector.so) and the plugin installer (myvectorplugin.sql):

- /usr/lib/mysql/plugin/myvector.so
- /docker-entrypoint-initdb.d/myvectorplugin.sql

Component images (mysql8.4-component, mysql9.7-component, mysql26.10) — the component library (still installed as myvector.so) plus the component install/uninstall scripts, which use INSTALL COMPONENT rather than INSTALL PLUGIN:

- /usr/lib/mysql/plugin/myvector.so
- /usr/lib/mysql/plugin/myvector.json
- /docker-entrypoint-initdb.d/myvector_install_component.sql   # auto-run on first start
- /usr/share/myvector/myvector_uninstall_component.sql          # manual teardown only

The uninstall script is deliberately kept out of /docker-entrypoint-initdb.d/ (everything there auto-runs on first startup, which would immediately undo the install). Run it by hand only when tearing the component down.

NOTE: The MySQL image entrypoint runs the initdb SQL script automatically on first startup. To re-run installation manually, source the install script for your image variant: - Plugin image: mysql -u root -p < /docker-entrypoint-initdb.d/myvectorplugin.sql - Component image: mysql -u root -p < /docker-entrypoint-initdb.d/myvector_install_component.sql (clean teardown: mysql -u root -p < /usr/share/myvector/myvector_uninstall_component.sql)

Quick Start (MySQL 8.4)

Start a container with a fresh data directory:

docker run -d \
  --name myvector-test \
  -e MYSQL_ROOT_PASSWORD=myvector \
  -e MYSQL_DATABASE=vectordb \
  -p 3306:3306 \
  ghcr.io/askdba/myvector:mysql8.4

Verify the plugin is loaded:

docker exec myvector-test mysql -uroot -pmyvector -e \
  "SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME='myvector';"

If the plugin/UDFs are missing (e.g., reused data directory), reinstall:

docker exec myvector-test mysql -uroot -pmyvector -e \
  "SOURCE /docker-entrypoint-initdb.d/myvectorplugin.sql;"

Stanford50d Sample Dataset (Working Example)

Create a table with a MYVECTOR column (note: use the MYVECTOR column syntax, not a COMMENT, so the plugin can rewrite the DDL properly):

docker exec -i myvector-test mysql -uroot -pmyvector vectordb <<'SQL'
DROP TABLE IF EXISTS words50d;
CREATE TABLE words50d (
  wordid INT AUTO_INCREMENT PRIMARY KEY,
  word VARCHAR(200),
  wordvec MYVECTOR(type=HNSW,dim=50,size=400000,dist=L2,m=64,ef=100)
);
SQL

Load the sample vectors (50d GloVe):

curl -L -o /tmp/insert50d.sql.gz \
  https://raw.githubusercontent.com/askdba/myvector/main/examples/stanford50d/insert50d.sql.gz
gunzip -c /tmp/insert50d.sql.gz | docker exec -i myvector-test mysql -uroot -pmyvector vectordb

Build the vector index:

docker exec myvector-test mysql -uroot -pmyvector -e \
  "CALL mysql.myvector_index_build('vectordb.words50d.wordvec','wordid');" vectordb

Run a similarity search (note: myvector_row_distance requires the id):

docker exec myvector-test mysql -uroot -pmyvector -e \
  "SET @school_vec = (SELECT wordvec FROM words50d WHERE word = 'school');
   SELECT word, myvector_row_distance(wordid) AS distance
   FROM words50d
   WHERE MYVECTOR_IS_ANN('vectordb.words50d.wordvec','wordid',@school_vec,10);" vectordb

MySQL 9.x (Native VECTOR Type Example)

Start a MySQL 9.x container (use --platform linux/amd64 on Apple Silicon):

docker run -d \
  --platform linux/amd64 \
  --name myvector-test-97 \
  -e MYSQL_ROOT_PASSWORD=myvector \
  -e MYSQL_DATABASE=vectordb \
  -p 3309:3306 \
  ghcr.io/askdba/myvector:mysql9.7

Configure MyVector to use TCP and set the index directory, then restart:

docker exec myvector-test-97 bash -lc "cat >/var/lib/mysql/myvector.cnf <<'EOF'
myvector_host=127.0.0.1
myvector_port=3306
myvector_user_id=root
myvector_user_password=myvector
EOF"
docker restart myvector-test-97
docker exec myvector-test-97 mysql -uroot -pmyvector -e \
  "SET GLOBAL myvector_index_dir='/var/lib/mysql';"

Create the table and load the sample vectors (native VECTOR type):

docker exec -i myvector-test-97 mysql -uroot -pmyvector vectordb <<'SQL'
DROP TABLE IF EXISTS words50d;
CREATE TABLE words50d (
  wordid INT AUTO_INCREMENT PRIMARY KEY,
  word VARCHAR(200),
  wordvec VECTOR(50) COMMENT 'MYVECTOR Column |type=HNSW,dim=50,size=400000,dist=L2,m=64,ef=100'
);
SQL

curl -L -o /tmp/insert50d.sql.gz \
  https://raw.githubusercontent.com/askdba/myvector/main/examples/stanford50d/insert50d.sql.gz
gunzip -c /tmp/insert50d.sql.gz | docker exec -i myvector-test-97 mysql -uroot -pmyvector vectordb

Build the vector index and run a similarity search:

docker exec myvector-test-97 mysql -uroot -pmyvector -e \
  "CALL mysql.myvector_index_build('vectordb.words50d.wordvec','wordid');" vectordb

docker exec myvector-test-97 mysql -uroot -pmyvector -e \
  "SET @school_vec = (SELECT wordvec FROM words50d WHERE word = 'school');
   SELECT word, myvector_row_distance(wordid) AS distance
   FROM words50d
   WHERE MYVECTOR_IS_ANN('vectordb.words50d.wordvec','wordid',@school_vec,10);" vectordb

Confirm the DDL was rewritten to the native VECTOR type:

docker exec myvector-test-97 mysql -uroot -pmyvector -e \
  "SHOW CREATE TABLE words50d;" vectordb

Index Build Connection Notes

If index build fails with a socket connection error, configure MyVector to use TCP inside the container and restart it:

docker exec myvector-test bash -lc "cat >/var/lib/mysql/myvector.cnf <<'EOF'
myvector_host=127.0.0.1
myvector_port=3306
myvector_user_id=root
myvector_user_password=myvector
EOF"
docker restart myvector-test

Then reinstall the plugin/UDFs once after restart:

docker exec myvector-test mysql -uroot -pmyvector -e \
  "SOURCE /docker-entrypoint-initdb.d/myvectorplugin.sql;"

After the plugin is installed/registered above, please follow the usage instructions in the main README:

https://github.com/askdba/myvector#-usage-examples

MyVector Demos

https://github.com/askdba/myvector/tree/main/examples/stanford50d

Versions

Tag MySQL Version Install mechanism
ghcr.io/askdba/myvector:mysql8.0 8.0.x Plugin (INSTALL PLUGIN)
ghcr.io/askdba/myvector:mysql8.4 8.4.x (Recommended) Plugin (INSTALL PLUGIN)
ghcr.io/askdba/myvector:mysql8.4-component 8.4.x Component (INSTALL COMPONENT)
ghcr.io/askdba/myvector:mysql9.7 9.7.x (LTS) Plugin (INSTALL PLUGIN)
ghcr.io/askdba/myvector:mysql9.7-component 9.7.x (LTS) Component (INSTALL COMPONENT)
ghcr.io/askdba/myvector:mysql26.10 26.10.x (Innovation) Component only (INSTALL COMPONENT)
ghcr.io/askdba/myvector:latest 8.0.x Plugin (INSTALL PLUGIN)

Each plugin image is based on the exact MySQL release its plugin was built against: a plugin or component built for one release can crash another. The image is also tagged with that release (mysql8.0.46, mysql8.4.13, mysql9.7.4); mysql8.0, mysql8.4, mysql9.7 and latest move to the new release when the build is updated.

Each component image is based on the exact MySQL release its component was built against: a component built for one patch release can crash another (an 8.4.8 build crashed 8.4.11). The image is also tagged with that release, e.g. mysql8.4.13-component, mysql9.7.4-component, mysql26.10.0; the version tags above move to the new release when the build is updated.

Component images (INSTALL COMPONENT) contain /usr/lib/mysql/plugin/myvector.so + myvector.json and /docker-entrypoint-initdb.d/myvector_install_component.sql, rather than the plugin's myvectorplugin.sql.