cmdxray / commands / docker

What does docker do?

build, run and manage containers.

▸ Explain your own docker command →

docker examples, explained

$ docker run -it --rm -p 8080:80 nginx

  • dockerbuild, run and manage containers
  • runcreate and start a new container
  • -ikeep STDIN open (interactive)
  • -tallocate a pseudo-terminal
  • --rmremove the container when it exits
  • -ppublish a container port to the host (host:container)
  • 8080:80value for -p
  • nginxan argument passed to the command

$ docker build -t myimg .

  • dockerbuild, run and manage containers
  • buildbuild an image from a Dockerfile
  • -ttag the built image (name:tag)
  • myimgvalue for -t
  • .an argument passed to the command

$ docker build -t app:1.0 --no-cache --build-arg VERSION=1 .

  • dockerbuild, run and manage containers
  • buildbuild an image from a Dockerfile
  • -ttag the built image (name:tag)
  • app:1.0value for -t
  • --no-cachebuild without using any cached layers
  • --build-argset a build-time variable (NAME=value)
  • VERSION=1value for --build-arg
  • .an argument passed to the command

docker subcommands

run — create and start a new containerbuild — build an image from a Dockerfileps — list running containersimages — list local imagesexec — run a command inside a running containerpull — download an image from a registrypush — upload an image to a registrystop — stop a running containerrm — remove a containerrmi — remove an imagelogs — show a container's outputcompose — run multi-container apps from a compose file

docker flags & options

-ddetached — run in the background
-itinteractive with a terminal attached
-ikeep STDIN open (interactive)
-tallocate a pseudo-terminal
-ppublish a container port to the host (host:container)
-vmount a volume (host path : container path)
-eset an environment variable
-wset the working directory inside the container
--rmremove the container when it exits
--namegive the container a name
--networkconnect the container to this network

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.