docker run -d -p 8080:80 nginx

docker run Command Builder

Set the image, map your ports and volumes, pick a restart policy, then copy a docker run command ready for your terminal or a compose file conversion.

e.g. nginx:latest, postgres:16, ghcr.io/owner/app:tag
Optional. Docker generates a random name if empty.
Prefix with an IP to bind to one interface instead of 0.0.0.0.
Paths starting with / are bind mounts; bare names are named volumes.
Optional. A user-defined bridge enables container-name DNS.
Optional command appended after the image.
docker run -d nginx:latest

Detached or interactive?

Use -d for services that should keep running in the background (web servers, databases). Use -it --rm for one-off interactive work like debugging shells, and drop both if you are wiring the container into a script that reads its stdout. -d and -it together rarely make sense.

Docker container launch helper

This docker run generator assembles the flags that self-hosters and developers reach for daily: port publishing, bind mounts and named volumes, environment variables, restart policies for surviving reboots, and network attachment. The output works unchanged with Podman, alias docker=podman and everything here still applies.

docker run FAQ

What is the difference between -v bind mounts and named volumes?

Bind mounts (/host/path:/container/path) expose an existing host directory into the container. Named volumes (name:/container/path) are managed by Docker under /var/lib/docker/volumes and are the better default for data you do not need to browse on the host.

Why can I not reach my published port from another machine?

Check that the port is published on 0.0.0.0 (the default) rather than 127.0.0.1, and that the host firewall allows the port. Note that Docker inserts its own iptables rules which bypass ufw by default.

Which restart policy should I use for a self-hosted service?

unless-stopped is the usual choice: the container restarts after crashes and reboots, but stays down if you deliberately stopped it. always will resurrect containers you stopped manually once the daemon restarts.

Does this work with Podman?

Yes. Podman implements the same CLI, so the generated command works with podman run directly. For rootless Podman, publishing ports below 1024 needs extra configuration.