How can I use docker run arguments in my deploy?

I want to be able to run docker run commands to create instances of applications on demand


docker run -d --name='test' -p 3303:3303 --env USERNAME=admin dockerhub/image:latest

However, I understand that only allows you to publish already-existing images via flyctl deploy and thus the docker run doesn’t exist in this context

How can I replicate the behaviour of docker run (the ability to configure arguments) when deploying an existing image via flyctl?

In my example, I don’t really care about the docker instance name, but I do care about the port mapping and --env variables

flyctl deploy -i$PROJECT:latest can be used to point to an image.
flyctl deploy -e KEY=VAL can be used to set more than one env variables.

Do note that env variables supplied here will not be available during the build.

Not sure about the port though…
EDIT: Something like this for ports maybe; in your fly.toml:

    port = ${PUHRT}

and then flyctl deploy -e PUHRT=9000 says that env variables can only be strings. I reckon it’s easy enough to test & find out.

1 Like