Programming Self-Study Notebook

勉強したことを忘れないように! 思い出せるように!!

Dockerインストール後の最初の一歩

f:id:overworker:20200628105903p:plain

0.コマンドプロンプトを起動する

f:id:overworker:20200627004720p:plain:h250

1.「Hello world」をやってみる

f:id:overworker:20200627003725p:plain:h150

1-1.Dockerコマンドを入力する

  • 実際に入力したコマンドは以下のものです。
docker container run ubuntu:latest /bin/echo 'Hello World'
  • 上記コマンドを入力した際のレスポンスが以下になります。
C:\Users\******>docker container run ubuntu:latest /bin/echo 'Hello World'
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
a4a2a29f9ba4: Pull complete
127c9761dcba: Pull complete
d13bf203e905: Pull complete
4039240d2e0b: Pull complete
Digest: sha256:35c4a2c15539c6c1e4e5fa4e554dac323ad0107d8eb5c582d6ff386b383b7dce
Status: Downloaded newer image for ubuntu:latest
'Hello World'

1-2.再度、同じDockerコマンドを入力する

  • 追記した結果が以下になります。
C:\Users\******>docker container run ubuntu:latest /bin/echo 'Hello World'
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
a4a2a29f9ba4: Pull complete
127c9761dcba: Pull complete
d13bf203e905: Pull complete
4039240d2e0b: Pull complete
Digest: sha256:35c4a2c15539c6c1e4e5fa4e554dac323ad0107d8eb5c582d6ff386b383b7dce
Status: Downloaded newer image for ubuntu:latest
'Hello World'

C:\Users\******>docker container run ubuntu:latest /bin/echo 'Hello World'
'Hello World'

解説

1回目のDockerコマンドの動作 1. Dockerコンテナのもととなる、UbuntuのDockerイメージがローカル環境にあるかを確認する 2. (ローカル環境にないので)DockerリポジトリからDockerイメージをダウンロードする 3. (ダウンロードが完了すると)コンテナが起動し、Linuxのechoコマンドが実行される

2回目のDockerコマンドの動作 1. Dockerコンテナのもととなる、UbuntuのDockerイメージがローカル環境にあるかを確認する 2. (ローカル環境にあるので)コンテナが起動し、Linuxのechoコマンドが実行される

2.使用しているDockerのバージョンを調べる

f:id:overworker:20200627011016p:plain:h150

2-1.Dockerコマンドを入力する①

  • 実際に入力したコマンドは以下のものです。
docker -v
  • 上記コマンドを入力した際のレスポンスが以下になります。
C:\Users\******>docker -v
Docker version 19.03.8, build afacb8b

2-2.Dockerコマンドを入力する②

  • 実際に入力したコマンドは以下のものです。
docker version
  • 上記コマンドを入力した際のレスポンスが以下になります。
C:\Users\******>docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:29:16 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

3.Dockerの実行環境を確認する

f:id:overworker:20200627015016p:plain:h150

3-1.Dockerコマンドを入力する

docker system info
  • 上記コマンドを入力した際のレスポンスが以下になります。
C:\Users\******>docker system info
Client:
 Debug Mode: false

Server:
 Containers: 2
  Running: 0
  Paused: 0
  Stopped: 2
 Images: 1
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 4.19.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 2
 Total Memory: 1.945GiB
 Name: docker-desktop
 ID: OXQY:6R3R:4RH5:FSEK:MXA5:CCRG:CPEM:TWKS:MAPK:WCXT:USNR:XVJ3
 Docker Root Dir: /var/lib/docker
 Debug Mode: true
  File Descriptors: 40
  Goroutines: 52
  System Time: 2020-06-26T16:47:47.78582226Z
  EventsListeners: 3
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine

4.Dockerのディスク利用状況を確認する

f:id:overworker:20200627015432p:plain:h150

4-1.Dockerコマンドを入力する

docker system df
  • 上記コマンドを入力した際のレスポンスが以下になります。
C:\Users\******>docker system df
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              1                   1                   73.86MB             0B (0%)
Containers          2                   0                   0B                  0B
Local Volumes       0                   0                   0B                  0B
Build Cache         0                   0                   0B                  0B

参考文献

以下の本を読みながら、Dockerの勉強を開始しました。

その他の記事へ