Repository: mlflow/mlflow

Issue:
[BUG] `pip: not found` on `mlflow models build-docker`
Thank you for submitting an issue. Please refer to our [issue policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md)
for information on what types of issues we address. For help with debugging your code, please refer to [Stack Overflow](https://stackoverflow.com/questions/tagged/mlflow).

Please fill in this template and do not delete it unless you are sure your issue is outside its scope.

### System information
- **Have I written custom code (as opposed to using a stock example script provided in MLflow)**: no
- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**: Macos/Alpine
- **MLflow installed from (source or binary)**: source
- **MLflow version (run ``mlflow --version``)**: 1.7.2
- **Python version**: 3.7.0
- **npm version, if running the dev UI**: no
- **Exact command to reproduce**: mlflow models build-docker -m runs:/{run_id}/model -n test:test

### Describe the problem
Describe the problem clearly here. Include descriptions of the expected behavior and the actual behavior.

From today building docker image stoped to work with this command `/bin/sh: 1: pip: not found`

### Code to reproduce issue
Provide a reproducible test case that is the bare minimum necessary to generate the problem.

Delete docker image cache and run specified above command. 

### Other info / logs
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks,
please include the full traceback. Large logs and files should be attached.

Building docker image for run: 11b73737169841fb867916b8788ce111
2020/04/12 21:18:07 INFO mlflow.models.cli: Selected backend for flavor 'python_function'
2020/04/12 21:18:24 INFO mlflow.models.docker_utils: Building docker image with name mlflow-image-vectors:latest
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl/
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/MLmodel
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/Dockerfile
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/mlflow_model.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__init__.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__/mlflow_model.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_utils/__pycache__/__init__.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__init__.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__init__.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__/keras_inception_v3_u128.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/__pycache__/__init__.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/models/keras_inception_v3_u128.py
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__pycache__
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/code/mlflow_image_vectors/__pycache__/__init__.cpython-37.pyc
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/python_model.pkl
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//model_dir/model/conda.yaml
/var/folders/m1/xp7nclf15g5cw_ty2b7n4fb80000gn/T/tmplxi4s8jl//Dockerfile
Sending build context to Docker daemon  35.33kB

Step 1/17 : FROM ubuntu:18.04
 ---> 4e5021d210f6
Step 2/17 : RUN apt-get -y update && apt-get install -y --no-install-recommends          wget          curl          nginx          ca-certificates          bzip2          build-essential          cmake          openjdk-8-jdk          git-core          maven     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 3e1b0ec18fb3
Step 3/17 : RUN curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
 ---> Using cache
 ---> b4b068e2d493
Step 4/17 : RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;
 ---> Using cache
 ---> 52f146aa012c
Step 5/17 : ENV PATH="/miniconda/bin:$PATH"
 ---> Using cache
 ---> 6e7758289f76
Step 6/17 : ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
 ---> Using cache
 ---> 20e01d0c1b79
Step 7/17 : ENV GUNICORN_CMD_ARGS="--timeout 60 -k gevent"
 ---> Using cache
 ---> 8d9d20195e8e
Step 8/17 : WORKDIR /opt/mlflow
 ---> Using cache
 ---> 51d39c46e3bc
Step 9/17 : RUN pip install mlflow==1.7.2
 ---> Running in b69369bccce1
/bin/sh: 1: pip: not found
The command '/bin/sh -c pip install mlflow==1.7.2' returned a non-zero code: 127


Discussion:
@kosteev It looks like your docker container does not contain pip. 

As part of your docker installation commands, you should add a line to install pip before attempting to install mlflow
I had the same error message "pip: not found".
What I have noticed from my console log is that 
```
Step 3/17 : RUN curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
 ---> Running in 5119867f0b51
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
```

This means that miniconda has not been correctly installed, hence no pip can be found.
Now I know what was wrong.
curl does not follow redirects without `-L` option.
So the step should have been like
```
Step 3/17 : RUN curl -L https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
```

I'll be submitting a PR to fix this.

Resolving patch:
diff --git a/mlflow/models/docker_utils.py b/mlflow/models/docker_utils.py
--- a/mlflow/models/docker_utils.py
+++ b/mlflow/models/docker_utils.py
@@ -29,7 +29,7 @@
     && rm -rf /var/lib/apt/lists/*
 
 # Download and setup miniconda
-RUN curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
+RUN curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh >> miniconda.sh
 RUN bash ./miniconda.sh -b -p /miniconda; rm ./miniconda.sh;
 ENV PATH="/miniconda/bin:$PATH"
 ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64


Test patch: