How to run a docker image as root / add options to docker run

I want to run a docker image as root and perhaps swap the users too.

Generally the command I use would be something like

docker run -it --name something -u 0 docker_container

In particular, I want to add the option -u 0 because I need some root permissions for debugging, otherwise I would normally leave it out.

However in prefect 2, there doesnt seem to be a way to specify the user (or pass through any other options?)

How can I start a docker image as root?

You can specify that as part of your Dockerfile:

I would like the option to switch between users for different containers without rebuilding/having separate dockerfiles, my (hypothetical) use case is to run one container as root using

docker run -it --name something -u 0 docker_container

and another container using

docker run -it --name something2 -u 2 docker_container

If there really is no way to do this using Prefect then I’ll do what you suggested… just thought there was a way to add options in code that’s all.

user is not something that typically changes at runtime - you can build separate DockerContainer blocks, each using a different image and user perhaps? you can have as many of such blocks as you need