Hi there. I am trying to use docker storage with a...
# ask-community
p
Hi there. I am trying to use docker storage with a custom Dockerfile that is based on an image that contains a conda environment. I am having an issue with the health checks failing, but the flow itself runs. Can you tell if I am doing something wrong? More details in thread.
The docker file:
Copy code
ARG IMAGE_TAG=latest
FROM <my_registry_url>/vscode:${IMAGE_TAG}

# Install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
    && apt-get -y install --no-install-recommends dos2unix

RUN mkdir /opt/ml
SHELL ["conda", "run", "-n", "standard_ml_20201110_py37", "/bin/bash", "-c"]
RUN pip install prefect==0.14.19 # "PyJWT<2.0.0"

ENTRYPOINT ["conda", "run", "-n", "standard_ml_20201110_py37"]
The flow:
Copy code
from dotenv import find_dotenv, load_dotenv
from prefect import Flow, task
from prefect.storage import Docker

load_dotenv(find_dotenv())


@task
def gen_data():
    return [1, 2, 3, 4]


@task
def print_data(data):
    print(data)


docker_storage = Docker(    
    dockerfile="flows/packaged_docker/Dockerfile",
    image_name="prefect-poc",
    image_tag="latest",
    python_dependencies=["sh"],
    ignore_healthchecks=True,
)

with Flow("Packaged-Docker-POC", storage=docker_storage) as flow:
    data = gen_data()
    print_data(data)


if __name__ == "__main__":
    flow.visualize(filename="packaged-docker")
    flow.register(project_name="FMINT", labels=["docker"])
The health check error I get:
Copy code
Step 14/15 : COPY ./tmpujuroceb/healthcheck.py /opt/prefect/healthcheck.py
 ---> 20ea31f8c64a
Step 15/15 : RUN python /opt/prefect/healthcheck.py '["/opt/prefect/flows/packaged-docker-poc.prefect"]' '(3, 7)'
 ---> Running in a694633ca6a6
ERROR conda.cli.main_run:execute(33): Subprocess for 'conda run ['/bin/bash', '-c', 'python /opt/prefect/healthcheck.py \'["/opt/prefect/flows/packaged-docker-poc.prefect"]\' \'(3, 7)\'']' command failed.  (See above for error)

/opt/conda/envs/standard_ml_20201110_py37/.tmpi23u0y9t: line 3: syntax error near unexpected token `('
/opt/conda/envs/standard_ml_20201110_py37/.tmpi23u0y9t: line 3: `/bin/bash -c 'python /opt/prefect/healthcheck.py '["/opt/prefect/flows/packaged-docker-poc.prefect"]' '(3, 7)'''
Thanks!
z
Hey @Pedro Machado -- this looks like a consequence of nested commands since you're overriding the
SHELL
in your Dockerfile
I'm honestly not sure of the best way to make this healthcheck command syntactically correct while nested like this, I would just ignore the healthcheck
p
Thanks, Michael