Skip to content

Docker: Basics: images & containers

11 Docker commands: Basics: images & containers. Click a command to see what each part does.

Index
11 items
Click a command to see what each part does.

Basics: images & containers11

  • docker version; docker infoIs Docker installed and running?

    What each part does

    1. docker versionclient and server (daemon) versions; an error on Server means the daemon is not running
    2. docker infosystem-wide details: containers, images, storage driver, cgroup driver
  • docker run --rm hello-worldTest that everything works

    What each part does

    1. docker runcreate and start a container (pulls the image if missing)
    2. --rmremove the container when it exits
    3. hello-worldtiny test image that prints a greeting
  • docker imagesList local images

    What each part does

    1. docker imagesalias of docker image ls: repository, tag, image ID, size
  • docker pull <image>:<tag>Download an image

    What each part does

    1. docker pulldownload from a registry (Docker Hub by default)
    2. <image>:<tag>e.g. nginx:1.27; without a tag it means :latest
  • docker ps; docker ps -aList running / all containers

    What each part does

    1. docker psrunning containers
    2. -ainclude stopped ones
  • docker start <container>; docker stop <container>; docker restart <container>Start, stop, restart a container

    What each part does

    1. startstart a stopped container (keeps its data and settings)
    2. stopgraceful stop: SIGTERM, then SIGKILL after 10s (-t to change)
    3. restartstop then start
  • docker rm <container>Remove a containerCaution

    What each part does

    1. docker rmdelete a stopped container; add -f to stop and delete a running one
  • docker rmi <image>:<tag>Remove an imageCaution

    What each part does

    1. docker rmidelete a local image; -f forces it even if tagged elsewhere
  • docker rename <old-name> <new-name>Rename a container

    What each part does

    1. docker renamechange the container name
  • docker port <container>Which host port maps to the container?

    What each part does

    1. docker portlist port mappings, e.g. 80/tcp -> 0.0.0.0:8080
  • docker login <registry>; docker logout <registry>Log in / out of a registry

    What each part does

    1. docker loginstore credentials (Docker Hub if no registry is given)
    2. docker logoutremove them

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…