Dockerでよく使うコマンド

dockerヘルプとイメージ関連コマンド docker

dockerでよく使うコマンドをまとめました。
自分用にメモしていたものを公開します。

dockerバージョン確認

コマンド:
# docker version
コマンド:
# docker info

dockerヘルプコマンド

コマンド:
docker –help
結果:
Usage:
  podman [flags]
  podman [command]
Available Commands:
  attach      Attach to a running container
  build       Build an image using instructions from Dockerfiles
  commit      Create new image based on the changed container
  container   Manage Containers
  cp          Copy files/folders between a container and the local filesystem
  create      Create but do not start a container
  diff        Inspect changes on container’s file systems
  events      Show podman events
  exec        Run a process in a running container
  export      Export container’s filesystem contents as a tar archive
  generate    Generated structured data
  healthcheck Manage Healthcheck
  help        Help about any command
  history     Show history of a specified image
  image       Manage images
  images      List images in local storage
  import      Import a tarball to create a filesystem image
  info        Display podman system information
  init        Initialize one or more containers
  inspect     Display the configuration of a container or image
  kill        Kill one or more running containers with a specific signal
  load        Load an image from container archive
  login       Login to a container registry
  logout      Logout of a container registry
  logs        Fetch the logs of a container
  mount       Mount a working container’s root filesystem
  pause       Pause all the processes in one or more containers
  play        Play a pod
  pod         Manage pods
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image from a registry
  push        Push an image to a specified destination
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Removes one or more images from local storage
  run         Run a command in a new container
  save        Save image to an archive
  search      Search registry for image
  start       Start one or more containers
  stats       Display a live stream of container resource usage statistics
  stop        Stop one or more containers
  system      Manage podman
  tag         Add an additional name to a local image
  top         Display the running processes of a container
  umount      Unmounts working container’s root filesystem
  unpause     Unpause the processes in one or more containers
  unshare     Run a command in a modified user namespace
  varlink     Run varlink interface
  version     Display the Podman Version Information
  volume      Manage volumes
  wait        Block on one or more containers
Flags:
      –cgroup-manager string        Cgroup manager to use (cgroupfs or systemd, default systemd)
      –cni-config-dir string        Path of the configuration directory for CNI networks
      –config string                Path of a libpod config file detailing container server configuration options
      –conmon string                Path of the conmon binary
      –cpu-profile string           Path for the cpu profiling results
      –default-mounts-file string   Path to default mounts file
      –events-backend string        Events backend to use
      –help                         Help for podman
      –hooks-dir strings            Set the OCI hooks directory path (may be set multiple times)
      –log-level string             Log messages above specified level: debug, info, warn, error, fatal or panic (default “error”)
      –namespace string             Set the libpod namespace, used to create separate views of the containers and pods on the system
      –network-cmd-path string      Path to the command for configuring the network
      –root string                  Path to the root directory in which data, including images, is stored
      –runroot string               Path to the ‘run directory’ where all state information is stored
      –runtime string               Path to the OCI-compatible binary used to run containers, default is /usr/bin/runc
      –storage-driver string        Select which storage driver is used to manage storage of images and containers (default is overlay)
      –storage-opt stringArray      Used to pass an option to the storage driver
      –syslog                       Output logging information to syslog as well as the console
      –tmpdir string                Path to the tmp directory
      –trace                        Enable opentracing output
      –version                      Version for podman
Use “podman [command] –help” for more information about a command.

ローカルのイメージ一覧を表示

コマンド:
# docker images
結果:
REPOSITORY                      TAG      IMAGE ID       CREATED         SIZE
docker.io/library/hello-world   latest   fce289e99eb9   10 months ago   6.14 kB

IMAGE IDのみ表示

コマンド:
# docker images -q
結果:
fce289e99eb9

hub.docker.comからイメージを検索する

コマンド:
docker search tomcat

index.docker.ioから指定したイメージを取り込む

コマンド:
docker pull tomcat

イメージを削除する(一つ)

コマンド:
docker rmi tomcat

イメージを削除する(複数)

コマンド:
docker rmi -f tomcat nginx

イメージを削除する(全部)

コマンド:
docker rmi -f $(docker images -qa)
タイトルとURLをコピーしました