Hello all, my company is happy with what I was abl...
# prefect-community
m
Hello all, my company is happy with what I was able to do with Prefect and wants to move forth with deploying it, however, I was told that we would prefer for Prefect itself to be in a docker container when we do the deployment. I do see that their is a docker image on docker hub, however I cannot locate any docs on how to build the image. Can someone point me in the right direction?
a
@Matthew Blau you have a couple of options here https://docs.prefect.io/orchestration/recipes/configuring_storage.html
m
Hi @Adam Roderick I have taken a look at this and it appears that this is for configuring flows to use docker storage, is that correct? I am looking to install prefect itself in a docker container from the image provided here https://hub.docker.com/r/prefecthq/prefect.
a
"however I cannot locate any docs on how to build the image" -- does this mean you are new to docker and want to know how to build an image? Or are you looking to customize the image?
m
I am fairly new to docker, yes. The images that I've worked with up til now have had build instructions. I'm looking to build and test what I was able to do previously.
a
That prefect image is pre-built. You don't need to build it, just run the docker pull command that is shown on the page. That will download the image to your local machine. Then you can start up a container from the image with the docker run command
m
Ahh! That is what I was missing in my understanding. Thank you!
@Adam Roderick I appear to be something wrong as when I attempt the docker run command this is the output I see:
Copy code
mblau@mblau-VirtualBox:~/docker_prefect$ docker -it run prefecthq/prefect:latest 
tini (tini version 0.18.0)
Usage: tini [OPTIONS] PROGRAM -- [ARGS] | --version

Execute a program under the supervision of a valid init process (tini)

Command line options:

  --version: Show version and exit.
  -h: Show this help message and exit.
  -s: Register as a process subreaper (requires Linux >= 3.4).
  -p SIGNAL: Trigger SIGNAL when parent dies, e.g. "-p SIGKILL".
  -v: Generate more verbose output. Repeat up to 3 times.
  -w: Print a warning when processes are getting reaped.
  -g: Send signals to the child's process group.
  -e EXIT_CODE: Remap EXIT_CODE (from 0 to 255) to 0.
  -l: Show license and exit.

Environment variables:

  TINI_SUBREAPER: Register as a process subreaper (requires Linux >= 3.4).
  TINI_VERBOSITY: Set the verbosity level (default: 1).
  TINI_KILL_PROCESS_GROUP: Send signals to the child's process group.
Could you advise?
j
Ah, the image doesn't set a command by default, you'll want to do something like
Copy code
docker run -it --rm prefecthq/prefect:latest /usr/bin/env bash
we'll want to update those docs, thanks for pointing that out.
m
@Jim Crist-Harif ah! Thank you. I have ran that command as you put it up there and it has dropped me into a root shell of the container. Is there anything else I need to do to get the UI up and running? My use case is to run other docker containers and I was successful in doing that with the install not in docker. Anything I should be aware of that needs handled in order for me to be able to talk to the other containers?
j
Ah, sorry, it wasn't clear to me what you were trying to do here. That just got you into an active session inside a prefect docker image. What is your goal here? Are you trying to run Prefect Server? Or build Prefect Flows as docker containers? Or?
m
I'm attempting to run Prefect Server so I can run existing docker containers. My company builds out docker containers for all our integrations and I am wanting to quickly move them over to being handled by prefect for orchestration. So far I've pulled down the docker image and want to get the Server Web UI up and running
j
Ah, gotcha. For that, you should run
prefect server start
(if you have docker running locally) and everything should just work. See https://docs.prefect.io/orchestration/server/deploy-local.html
The
prefecthq/prefect
image is for running flows, not prefect server (that's a separate set of images).
m
@Jim Crist-Harif ah so then the supported method of installing the server is via pip or a virtual environment? I had already done pip install prefect and wanted to use the prefect docker image as my boss indicated he would like it to be dockerized for running in production. But if that's not a supported method of running it I can likely convince him of using a virtual environment instead
j
Prefect Server is composed of multiple services. We provide a
docker-compose
backed setup for deploying it as a set of docker containers by running
prefect server start
. This requires a local install of
prefect
to run the initial command, but the actual server services run inside several docker containers in your environment.
m
Ahh so I should just install it via pipenv install --pre prefect
j
Sure, that'd work.
m
@Jim Crist-Harif awesome! I shall advise my boss that is the route we will be taking.
@Jim Crist-Harif One last question for now, if I can bother you some more, I had noticed that in my testing of starting and stopping the server projects that I create do not always persist. Is this the relevant bit of documentation that I should be referencing to ensure that things like that will persist in the event of the server going offline for any reason? https://docs.prefect.io/core/concepts/persistence.html
j
If you're starting and stopping Prefect Server, you'll need to persist the database somewhere. See https://docs.prefect.io/orchestration/server/deploy-local.html#database-persistence-and-migrations for how to do this in a dockerized setup.
The docs you linked are for persisting data at the flow-run-level (which is different than the data that prefect server persists)
m
Ah awesome! Thank you again. I am getting the hang of your documentation though I do get lost sometimes in it. We are looking to deploy this corp wide in the coming days so I want to make sure I take all the necessary steps to configure it in a way that is the best and sanest way of setting up
j
Great! We also have a new helm chart if a kubernetes based deployment would make more sense for you (and there's always Prefect Cloud for our hosted offering). Lots of ways to get a production setup going.
m
@Jim Crist-Harif one more question, if you don't mind. As we will be deploying this to production shortly and
Copy code
prefect server start
has a whole bunch of logging information in the terminal, is there a best practices deployment strategy that allows for us to hide that away like we would pipe other things to dev/null so that it can continue to run without being in the foreground? Any docs that you can point me to?
j
We just added an option to start all services in the background.
Copy code
prefect server start -d
should start all your services as docker containers, then return with them running in the background. You can do
Copy code
prefect server stop
later to stop everything. This requires prefect 0.14.1, which was just released today.
m
Oh perfect! so when I do the pipenv install of Prefect it will pull down and install the latest version, correct? and can I chain flags together like :
Copy code
prefect server start -d --use-volume
so I can configure persistence as well?
j
it will pull down and install the latest version, correct?
I'm not familiar with pipenv, but most tools for installing python libraries install the latest versions by default. You can check your version of prefect with
prefect version
. And yes, the above command should work fine.
m
@Jim Crist-Harif btw https://docs.prefect.io/orchestration/server/deploy.html#database-persistence-and-migrations 404's. I was trying to click on "persistent volume"
j
Thanks! I'll put a fix up now.
That should link to the heading above that section, FYI