Run a container
high risk
docker run --rm --read-only --cap-drop ALL --security-opt no-new-privileges <image>Hardened run optionsCreates and starts a container from an image.
| Flag | Meaning |
|---|---|
-d | Detached |
-p | Publish port host:container |
-v | Mount volume or host path⚠ Mounting / or the Docker socket gives host control. |
--rm | Remove container on exit |
--privileged --privileged | Full host access⚠ Disables isolation. |
-e | Environment variable⚠ Visible in docker inspect. |
--network host | Host networking⚠ Bypasses network isolation. |
--user | Run as user |
docker run --rm -it alpine shThrowaway shell · explain & risk-check →docker run -d --name web -p 8080:80 nginx:1.27Run nginx · explain & risk-check →Reference text is hand-written and may be incomplete — check man docker for your version. Test destructive commands on a non-production system first.