Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
Showing results for 
Search instead for 
Did you mean: 

Deploy model to AWS Sagemaker: ModuleNotFoundError: No module named 'docker'

New Contributor III


When trying to run the following command:

mlflow sagemaker build-and-push-container

I get the following error:

/databricks/python3/lib/python3.9/site-packages/click/ UserWarning: Virtualenv support is still experimental and may be changed in a future release without warning.
  value = self.callback(ctx, self, value)
2023/06/12 16:22:04 INFO mlflow.models.docker_utils: Building docker image with name mlflow-pyfunc
Traceback (most recent call last):
  File "/databricks/python3/bin/mlflow", line 8, in <module>
  File "/databricks/python3/lib/python3.9/site-packages/click/", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/databricks/python3/lib/python3.9/site-packages/click/", line 1053, in main
    rv = self.invoke(ctx)
  File "/databricks/python3/lib/python3.9/site-packages/click/", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/databricks/python3/lib/python3.9/site-packages/click/", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/databricks/python3/lib/python3.9/site-packages/click/", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/databricks/python3/lib/python3.9/site-packages/click/", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/databricks/python3/lib/python3.9/site-packages/mlflow/sagemaker/", line 605, in build_and_push_container
  File "/databricks/python3/lib/python3.9/site-packages/mlflow/models/", line 224, in _build_image
    _build_image_from_context(context_dir=cwd, image_name=image_name)
  File "/databricks/python3/lib/python3.9/site-packages/mlflow/models/", line 228, in _build_image_from_context
    import docker
ModuleNotFoundError: No module named 'docker'

I installed docker by running the following command:

%pip install docker

But the error still persists. Please note that I am running the above code in a Databricks notebook.

Using the UI, I have also tried installing docker from Databricks' built-in package manager -- again to no avail.

Could I please get some assistance figuring this out?


Community Manager
Community Manager

Hi @Nikhil Gajghate​, Which cluster are you working on?

1 Driver

128 GB Memory, 32 CoresRuntime


Unity Catalog


5.7 DBU/h

Runtime version: 12.2 LTS ML (includes Apache Spark 3.3.2, Scala 2.12)

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!