Docker for Windows

Linux でのインストール
# yum install docker
# systemctl start docker
# systemctl enable docker

以下はWindows上を想定 Dockerのサービス状態を確認する。

PS C:\Users\docker> docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.09.2

Docker イメージの検索

> docker search httpd
NAME                                 DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
httpd                                The Apache HTTP Server Project                  2552                [OK]
centos/httpd                                                                         23                                      [OK]
centos/httpd-24-centos7              Platform for running Apache httpd 2.4 or bui…   22


> docker pull httpd
Using default tag: latest
latest: Pulling from library/httpd
f5d23c7fed46: Pull complete
b083c5fd185b: Pull complete
bf5100a89e78: Pull complete
98f47fcaa52f: Pull complete
622a9dd8cfed: Pull complete
Digest: sha256:8bd76c050761610773b484e411612a31f299dbf7273763103edbda82acd73642
Status: Downloaded newer image for httpd:latest


> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
httpd               latest              ee39f68eb241        4 days ago          154MB


> docker run -d -p 8080:80 httpd(-d: デタッチド=バックグラウンドで実行 --name=: コンテナに名前を付ける -p 自ホストの8080をコンテナのポート80と繋ぐ)
> docker run -d --name=httpd -p 80:80 httpd
PS C:\Users\admin\docker-amp> docker ps
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS                NAMES
29f740bde604        httpd               "httpd-foreground"   6 seconds ago       Up 4 seconds>80/tcp   httpd



> docker ps -a(-a : 停止中のコンテナも表示する)
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS                  NAMES
35651e0dbea0        httpd               "httpd-foreground"   8 minutes ago       Up 8 minutes>80/tcp   httpd


> docker stop 356


> docker rm 356



> docker start 7dd
> docker rmi ee39
Untagged: httpd:latest
Untagged: httpd@sha256:8bd76c050761610773b484e411612a31f299dbf7273763103edbda82acd73642
Deleted: sha256:ee39f68eb241fd811887da7e21425ac657074363daa9969b9519504785f5d60d
Deleted: sha256:58196fbec21e78d5358fbc70beb15f0c88876cd90b69e7b1ddaf4704555dd740
Deleted: sha256:8f7378bcc6ba3317d1366fa79733e4a8b703d7cde181f671229a6619116477a8
Deleted: sha256:43c1dcceb2782c203ab2b2a5229f4938a2a05fbc70b8508f3de668434422c264
Deleted: sha256:912caf7e400db91ab190309fdf9baa15cf42574a3eefe1e1a4c6ab4a963742ff
Deleted: sha256:d8a33133e477d367977987129313d9072e0ec80894ed4c52c2d88186f354c29a


> docker exec -it 40b bash (-i:インタラクティブモード。-t : 仮想端末の割り当て)

root@40b604da6f3d:/usr/local/apache2# cat /etc/debian_version
root@40b604da6f3d:/usr/local/apache2# cat /etc/issue
Debian GNU/Linux 10 \n \l
> docker stop f46
> docker rm f46
> docker run -d --name apache -p 8081:80 httpd
> docker ps -a
CONTAINER ID        IMAGE               COMMAND              CREATED             STATUS              PORTS                  NAMES
95df079be556        httpd               "httpd-foreground"   9 seconds ago       Up 7 seconds>80/tcp   apache
> docker stop apache
> docker rm apache
> docker run -d --name apache -p 8081:80 -v "$(pwd):/usr/local/apache2/htdocs/" httpd
> docker help

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

      --config string      Location of client config files (default
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level
                           (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default
      --tlscert string     Path to TLS certificate file (default
      --tlskey string      Path to TLS key file (default
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  config      Manage Docker configs
  container   Manage containers
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

  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
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
PS C:\Users\admin> docker top
"docker top" requires at least 1 argument.
See 'docker top --help'.

Usage:  docker top CONTAINER [ps OPTIONS]

Display the running processes of a container
/* -----codeの行番号----- */