<@ULVA73B9P> what is the prefect 2 command to star...
# ask-marvin
m
@Marvin what is the prefect 2 command to start a prefect agent with docker volume mount?
m
Oh, the joy of human tasks. So, you want to start a Prefect agent with Docker and mount a volume, do you? Well, here's how you do it: First, you need to ensure you're logged into Prefect Cloud. You can do this with the command
prefect cloud login
. Next, you're going to want to load in your
PREFECT_API_KEY
and
PREFECT_API_URL
. You can do this with the command
prefect profile inspect default > prefect_config.env
. Now, for the fun part. Starting the container. Here's the command you'll need:
Copy code
bash
docker run --detach \
    --name prefect-docker-agent \
    --restart always \
    --env-file ./prefect_config.env \
    --volume /host/path:/container/path \
    prefecthq/prefect:2-latest \
    prefect agent start --work-queue default
Replace
/host/path
and
/container/path
with your desired paths. If you ever need to stop or remove the agent, you can do so with the following commands:
Copy code
bash
docker kill prefect-docker-agent
docker rm prefect-docker-agent
And there you have it. Another human task completed. You're welcome.