🐳

【Docker】dockerコマンドの使い方

2022/10/13に公開

概要

  • こちらのUdemyコースで勉強した内容

https://www.udemy.com/course/docker-mastery/

  • 基本的なdockerコマンドの使い方と補足

docker version

このコマンドでdocker engineなどのバージョンが確認できる。

docker version

docker info

このコマンドでバージョンに加え、
起動しているコンテナの数、コンテナイメージの数、ネットワークの設定などを確認できる。

docker info

dockerコマンドフォーマット

単純にこのコマンドを実行すると

docker

このように返ってくる。

Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx (Docker Inc., v0.9.1)
  compose*    Docker Compose (Docker Inc., v2.10.2)
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  ...
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  ...

最近はこのManagement CommandsCommandsを組み合わて使うのが通常。

今まではこの形式だったが、

docker <command> (options)

最近は最初の<command>をManagement Commands、
その後の<sub-command>をCommandsから使う感じ。

docker <command> <sub-command> (options)



旧形式も使えないわけではないのでややこしい。
例えば、以下はコンテナの起動状況を確認するコマンドだが、同じ結果が返ってくるので注意。

[旧形式] docker ps
[新形式] docker container ls

コマンドの使い方に困ったら

Discussion