306:3306 -e MYSQL_ROOT_PASSWORD=password mysql:8.0The ZenML client on the host machine can then be configured to connect directly to the database with a slightly different zenml connect command:

zenml connect --url mysql://127.0.0.1/zenml --username root --password password

Note The localhost hostname will not work with MySQL databases. You need to use the 127.0.0.1 IP address instead.

ZenML server with docker-compose

Docker compose offers a simpler way of managing multi-container setups on your local machine, which is the case for instance if you are looking to deploy the ZenML server container and connect it to a MySQL database service also running in a Docker container.

To use Docker Compose, you need to install the docker-compose plugin on your machine first.

A docker-compose.yml file like the one below can be used to start and manage the ZenML server container and the MySQL database service all at once:

version: "3.9"

services:

mysql:

image: mysql:8.0

ports:

3306:3306

environment:

MYSQL_ROOT_PASSWORD=password

zenml:

image: zenmldocker/zenml-server

ports:

"8080:8080"

environment:

ZENML_STORE_URL=mysql://root:password@host.docker.internal/zenml

links:

mysql

depends_on:

mysql

extra_hosts:

"host.docker.internal:host-gateway"

restart: on-failure

Note the following:

ZENML_STORE_URL is set to the special Docker host.docker.internal hostname to instruct the server to connect to the database over the Docker network.

The extra_hosts section is needed on Linux to make the host.docker.internal hostname resolvable from the ZenML server container.

To start the containers, run the following command from the directory where the docker-compose.yml file is located:

docker-compose -p zenml up  -d

or, if you need to use a different filename or path:

docker-compose -f /path/to/docker-compose.yml -p zenml up -d