2020/11/10
今回できたこと
Dockerコマンドの中で、新たに、inspect, attach, exec, rm, images, rmiなどの動作を確認した
未解決
(K8sで起動された?)不要なDocker/K8sプロセスの停止
お約束
文章化作業
定例作業
未解決:不要なDocker/K8Sプロセスの停止
色々な作業をしてきたせいか、以下のように(おそらくK8S関連の)多数のDockerイメージが起動されている状態になっている。
code:shell
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1c5bd8e9f210 e3b0157be3f6 "kube-apiserver --ad…" 57 minutes ago Up 57 minutes k8s_kube-apiserver_kube-apiserver-raspberrypi_kube-system_a124ef93b19097b3b82f77f115bea234_3
f43a6372c208 k8s.gcr.io/pause:3.2 "/pause" 57 minutes ago Up 57 minutes k8s_POD_kube-apiserver-raspberrypi_kube-system_a124ef93b19097b3b82f77f115bea234_0
542291a7b778 2e91dde7e952 "etcd --advertise-cl…" 57 minutes ago Up 57 minutes k8s_etcd_etcd-raspberrypi_kube-system_8e10a808e3a10251878719ed9a902b7d_8
d82187f2e6c2 20bc29abb875 "kube-controller-man…" 57 minutes ago Up 57 minutes k8s_kube-controller-manager_kube-controller-manager-raspberrypi_kube-system_e62b2227a6ec5a736f0cde5142d3e382_6
48c359049c7f k8s.gcr.io/pause:3.2 "/pause" 57 minutes ago Up 57 minutes k8s_POD_etcd-raspberrypi_kube-system_8e10a808e3a10251878719ed9a902b7d_0
3c5441012d3c k8s.gcr.io/pause:3.2 "/pause" 57 minutes ago Up 57 minutes k8s_POD_kube-controller-manager-raspberrypi_kube-system_e62b2227a6ec5a736f0cde5142d3e382_0
565fdfa09a63 82bf37d955bb "kube-scheduler --au…" 57 minutes ago Up 57 minutes k8s_kube-scheduler_kube-scheduler-raspberrypi_kube-system_ee4c94eb845abf1878fb3c4c489b1365_6
c3792168c0b9 k8s.gcr.io/pause:3.2 "/pause" 57 minutes ago Up 57 minutes k8s_POD_kube-scheduler-raspberrypi_kube-system_ee4c94eb845abf1878fb3c4c489b1365_0
a8d2dc8f8725 ee0ec6d8ead3 "/usr/local/bin/kube…" 57 minutes ago Up 57 minutes k8s_kube-proxy_kube-proxy-fhhvz_kube-system_22ba655d-d9bf-4c8b-ba53-4a2d8b265155_5
9d4342378d1a k8s.gcr.io/pause:3.2 "/pause" 57 minutes ago Up 57 minutes k8s_POD_kube-proxy-fhhvz_kube-system_22ba655d-d9bf-4c8b-ba53-4a2d8b265155_0
以下のように、動作しているDockerイメージを無理矢理停止しても、K8Sの自動回復が効いているのか、再度複数のイメージが起動されてしまう。
code:shell
$ sudo docker ps|awk '{print "docker rm -f "$1}'|sudo sh
Error: No such container: CONTAINER
a5697e688ac8
98b229686b27
925c2676decd
c300215ca29c
95398d404b44
3e9b1dcc2124
7bce88bd3f20
ac48857340a2
6b08f431393e
b834412af118
$ sudo docker images|wc
13 90 1343
K8Sのkubectlとkubeadmの機能を確認する。
code:shell
$ kubectl help
kubectl controls the Kubernetes cluster manager.
Basic Commands (Beginner):
create Create a resource from a file or from stdin.
expose Take a replication controller, service, deployment or pod and expose it as a new Kubernetes Service
run Run a particular image on the cluster
set Set specific features on objects
Basic Commands (Intermediate):
explain リソースの説明を表示する
get 1つまたは複数のリソースを表示する
edit Edit a resource on the server
delete Delete resources by filenames, stdin, resources and names, or by resources and label selector
Deploy Commands:
rollout Manage the rollout of a resource
scale Set a new size for a Deployment, ReplicaSet or Replication Controller
autoscale Auto-scale a Deployment, ReplicaSet, or ReplicationController
Cluster Management Commands:
certificate Modify certificate resources.
cluster-info クラスターの情報を表示する
top Display Resource (CPU/Memory/Storage) usage.
cordon Mark node as unschedulable
uncordon Mark node as schedulable
drain Drain node in preparation for maintenance
taint Update the taints on one or more nodes
Troubleshooting and Debugging Commands:
describe Show details of a specific resource or group of resources
logs Print the logs for a container in a pod
attach Attach to a running container
exec Execute a command in a container
port-forward Forward one or more local ports to a pod
proxy Run a proxy to the Kubernetes API server
cp Copy files and directories to and from containers.
auth Inspect authorization
Advanced Commands:
diff Diff live version against would-be applied version
apply ファイル名または標準入力でリソースにコンフィグを適用する
patch Update field(s) of a resource using strategic merge patch
replace Replace a resource by filename or stdin
wait Experimental: Wait for a specific condition on one or many resources.
convert Convert config files between different API versions
kustomize Build a kustomization target from a directory or a remote url.
Settings Commands:
label リソースのラベルを更新する
annotate リソースのアノテーションを更新する
completion Output shell completion code for the specified shell (bash or zsh)
Other Commands:
alpha Commands for features in alpha
api-resources Print the supported API resources on the server
api-versions Print the supported API versions on the server, in the form of "group/version"
config kubeconfigを変更する
plugin Provides utilities for interacting with plugins.
version Print the client and server version information
Usage:
Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
code:shell
$ kubeadm help
┌──────────────────────────────────────────────────────────┐
│ KUBEADM │
│ Easily bootstrap a secure Kubernetes cluster │
│ │
│ Please give us feedback at: │
└──────────────────────────────────────────────────────────┘
Example usage:
Create a two-machine cluster with one control-plane node
(which controls the cluster), and one worker node
(where your workloads, like Pods and Deployments run).
┌──────────────────────────────────────────────────────────┐
│ On the first machine: │
├──────────────────────────────────────────────────────────┤
│ control-plane# kubeadm init │
└──────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────┐
│ On the second machine: │
├──────────────────────────────────────────────────────────┤
│ worker# kubeadm join <arguments-returned-from-init> │
└──────────────────────────────────────────────────────────┘
You can then repeat the second step on as many other machines as you like.
Usage:
Available Commands:
alpha Kubeadm experimental sub-commands
completion Output shell completion code for the specified shell (bash or zsh)
config Manage configuration for a kubeadm cluster persisted in a ConfigMap in the cluster
help Help about any command
init Run this command in order to set up the Kubernetes control plane
join Run this on any machine you wish to join an existing cluster
reset Performs a best effort revert of changes made to this host by 'kubeadm init' or 'kubeadm join'
token Manage bootstrap tokens
upgrade Upgrade your cluster smoothly to a newer version with this command
version Print the version of kubeadm
Flags:
--add-dir-header If true, adds the file directory to the header of the log messages
-h, --help help for kubeadm
--log-file string If non-empty, use this log file
--log-file-max-size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
--rootfs string EXPERIMENTAL The path to the 'real' host root filesystem. --skip-headers If true, avoid header prefixes in the log messages
--skip-log-headers If true, avoid headers when opening log files
-v, --v Level number for the log level verbosity
Use "kubeadm command --help" for more information about a command. めぼしそうなコマンドを入力しても、以下のようにcertificate関連のエラーが出てしまう。
code:shell
$ kubectl explain
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
$ kubectl cluster-info
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
$ kubectl cluster-info dump
Unable to connect to the server: x509: certificate signed by unknown authority (possibly because of "crypto/rsa: verification error" while trying to verify candidate authority certificate "kubernetes")
現状、不要なコンテナの停止方法は不明だが、とりあえず他の作業を行う。
Dockerのコマンド指定なし起動状態の維持
2020/11/09の作業で、docker runのコマンドラインオプションで/bin/bashを起動したコンテナをcommitした時、新しいコンテナではコマンドラインオプション指定なしの時に/bin/bashが起動する状態に変更されていた。 今回、作業用シェルの実行にdocker execを使った場合、起動するコマンドがどうなるか確認する。
docker execを実行すると、任意のプロセスを指定したDocker内で実行することができる。
docker execのhelpは以下の通り。
code:shell
$ sudo docker help exec
Run a command in a running container
Options:
-d, --detach Detached mode: run command in the background
--detach-keys string Override the key sequence for detaching a container
-e, --env list Set environment variables
-i, --interactive Keep STDIN open even if not attached
--privileged Give extended privileges to the command
-t, --tty Allocate a pseudo-TTY
-u, --user string Username or UID (format: <name|uid>:<group|gid>) -w, --workdir string Working directory inside the container
ID:4e9aef546e01で実行されているコンテナで、/bin/bashを実行し、/index.htmlの内容を編集し、動作を確認する。
この時、このコンテナは、実行コマンドの指定を行なっていないため、httpdが動いている状態である。
code:shell
$ sudo docker exec -it 4e9aef546e01 /bin/bash
root@4e9aef546e01:/usr/local/apache2# cat htdocs/index.html
<html><body><h1>It works!</h1></body></html>
root@4e9aef546e01:/usr/local/apache2# echo "My page">htdocs/index.html
root@4e9aef546e01:/usr/local/apache2# cat htdocs/index.html
My page
code:shell
$ telnet 172.17.0.2 80
Trying 172.17.0.2...
Connected to 172.17.0.2.
Escape character is '^]'.
GET /index.html
My page
Connection closed by foreign host.
この状態のイメージを、my_httpd_20201110_01という名前でcommitする。
code:shell
$ sudo docker commit 4e9aef546e01 my_httpd_20201110_01
sha256:ea0cef820e00a6d935c9b1f731030877054c054f3098c24a6ff30875780f585e
作成したイメージmy_httpd_20201110_01をコマンドを指定することなく実行すると、httpdが起動する状態となっている。
これは、2020/11/09の疑問点であったdocker runでコマンド指定なしの実行をした時に、httpdが動かず/bin/bashが動く状態になってしまったことの、解決策になる。 code:shell
$ sudo docker run my_httpd_20201110_01
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.17.0.3. Set the 'ServerName' directive globally to suppress this message
このコンテナのhttpdの動作に関しては、以下の様に確認した。
code:shell
$ sudo docker ps|grep httpd
f38670ffa6d0 my_httpd_20201110_01 "httpd-foreground" About a minute ago Up About a minute 80/tcp hungry_hertz
4e9aef546e01 httpd "httpd-foreground" 13 minutes ago Up 13 minutes 80/tcp ecstatic_cray
$ sudo docker exec f38670ffa6d0 ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.0.3 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:ac:11:00:03 txqueuelen 0 (Ethernet)
RX packets 35 bytes 5368 (5.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3 bytes 562 (562.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ telnet 172.17.0.3 80
Trying 172.17.0.3...
Connected to 172.17.0.3.
Escape character is '^]'.
GET /index.html
My page
Connection closed by foreign host.
Dockerコマンドの機能確認
dockerコマンドのhelpを参考に、使えそうなコマンドの動作を確認する。
code:shell
% docker help
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"/home/mutoh/.docker")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level
("debug"|"info"|"warn"|"error"|"fatal")
(default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default
"/home/mutoh/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default
"/home/mutoh/.docker/cert.pem")
--tlskey string Path to TLS key file (default
"/home/mutoh/.docker/key.pem")
--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
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
deploy Deploy a new stack or update an existing stack
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.
docker attachを実行すると、docker runで実行しているコンテナに接続することができる。
例えば、/bin/bashが動いているコンテナにattachすると、attachした側でも/bin/bashの操作ができるようになる。
この時、attach側で入出力した内容は、attachした側でも入出力され、ターミナルマルチプレキサの様な動作をする。
code:shell
# attachされる側(docker runで実行した側)
$ sudo docker run -it httpd /bin/bash
root@809b4da8b556:/usr/local/apache2# ls
bin build cgi-bin conf error htdocs icons include logs modules
# attachした側
$ sudo docker attach 809b4da8b556
root@809b4da8b556:/usr/local/apache2# ls
bin build cgi-bin conf error htdocs icons include logs modules
docker imagesコマンドは、dockerにインストールされているイメージの一覧を表示する。
code:shell
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
my_httpd_20201110_01 latest ea0cef820e00 4 hours ago 172MB
my_httpd3 latest 27c8f2b6826a 24 hours ago 200MB
my_httpd2 latest 7dd1f7c206bb 24 hours ago 200MB
my_httpd latest b52faa97791a 25 hours ago 174MB
<none> <none> d1340644b198 27 hours ago 141MB
k8s.gcr.io/kube-proxy v1.19.3 ee0ec6d8ead3 3 weeks ago 97.3MB
k8s.gcr.io/kube-apiserver v1.19.3 e3b0157be3f6 3 weeks ago 96.7MB
k8s.gcr.io/kube-controller-manager v1.19.3 20bc29abb875 3 weeks ago 90.1MB
k8s.gcr.io/kube-scheduler v1.19.3 82bf37d955bb 3 weeks ago 38.3MB
httpd latest af8a8b04781c 4 weeks ago 120MB
k8s.gcr.io/etcd 3.4.13-0 2e91dde7e952 2 months ago 285MB
k8s.gcr.io/coredns 1.7.0 15c1a66b013b 4 months ago 37.6MB
k8s.gcr.io/pause 3.2 88d88dc74807 8 months ago 325kB
これらのイメージは、実行されていない時にdocker rmiコマンドで消去できる。
イメージが実行されていない状態でも以下の様なエラーが出たため、-fコマンドラインオプションを指定する必要があった。
code:shell
$ sudo docker rmi my_httpd3
Error response from daemon: conflict: unable to remove repository reference "my_httpd3" (must force) - container 6bf7ab53d994 is using its referenced image 27c8f2b6826a
$ sudo docker rmi -f my_httpd3
Untagged: my_httpd3:latest
Deleted: sha256:27c8f2b6826a4ebdfc777dbe27b09e65b08636706c6dea9f503e7b01bd3437f7
試しに、今止められなくて困っているコンテナイメージを消そうとしても、以下の様にエラーになる。
これらのコンテナのイメージ名がREPOSITORY名と異なっている様で、うまく指定できていない。
また、IMAGE IDで指定しても、消去できない。
code:shell
$ sudo docker rmi -f k8s.gcr.io/kube-proxy
Error: No such image: k8s.gcr.io/kube-proxy
$ sudo docker rmi -f ee0ec6d8ead3
Error response from daemon: conflict: unable to delete ee0ec6d8ead3 (cannot be forced) - image is being used by running container a8d2dc8f8725
docker inspectはDockerコンテナの状態をJSON形式で表示する。
大量の情報が出てくるので、現状あまり理解できていないが、使えそうな情報がかなり含まれている様に見える。
code:shell
$ sudo docker ps|grep http
8d355298ca23 my_httpd_20201110_01 "httpd-foreground" 3 seconds ago Up 3 seconds 80/tcp interesting_blackburn
$ sudo docker inspect 8d355298ca23
[
{
"Id": "8d355298ca2356edf8395c0c40c0adeed5ed364652021d2b8322a7f82e846983",
"Created": "2020-11-10T04:39:15.01432848Z",
"Path": "httpd-foreground",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 1811,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-11-10T04:39:15.863035521Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:ea0cef820e00a6d935c9b1f731030877054c054f3098c24a6ff30875780f585e",
"ResolvConfPath": "/var/lib/docker/containers/8d355298ca2356edf8395c0c40c0adeed5ed364652021d2b8322a7f82e846983/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/8d355298ca2356edf8395c0c40c0adeed5ed364652021d2b8322a7f82e846983/hostname",
"HostsPath": "/var/lib/docker/containers/8d355298ca2356edf8395c0c40c0adeed5ed364652021d2b8322a7f82e846983/hosts",
"LogPath": "/var/lib/docker/containers/8d355298ca2356edf8395c0c40c0adeed5ed364652021d2b8322a7f82e846983/8d355298ca2356edf8395c0c40c0adeed5ed364652021d2b8322a7f82e846983-json.log",
"Name": "/interesting_blackburn",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/e2c8fde49a965eaeffd36c8acdd74a88a82f2228621c813544e3ad8f0a8d0940-init/diff:/var/lib/docker/overlay2/d844ed406f251e7e341b5d1aca9f629e9f39d08d9ecc2578a6635df4bab79ecd/diff:/var/lib/docker/overlay2/7856653887edd2dd1ba876e02cb80dc6fa73ed989fed9bd7f7341358c14b220b/diff:/var/lib/docker/overlay2/384fad5da2e64e97444d5f20e5ac5c4d6da16437a8cf1a7e44d3df7e94e97fa9/diff:/var/lib/docker/overlay2/4e171e79ec9425a550179cf0c4bdf949c064e6f6290d1367400dba0cefcfd43e/diff:/var/lib/docker/overlay2/85a61fd1b2a161abb0edc16a482420ac115f09036b3e90cbf6d7db364a5066d6/diff:/var/lib/docker/overlay2/e8f9404bab50021f0232d6d04b1300410cc7e55ac2806203de3f36ea7b64ddea/diff",
"MergedDir": "/var/lib/docker/overlay2/e2c8fde49a965eaeffd36c8acdd74a88a82f2228621c813544e3ad8f0a8d0940/merged",
"UpperDir": "/var/lib/docker/overlay2/e2c8fde49a965eaeffd36c8acdd74a88a82f2228621c813544e3ad8f0a8d0940/diff",
"WorkDir": "/var/lib/docker/overlay2/e2c8fde49a965eaeffd36c8acdd74a88a82f2228621c813544e3ad8f0a8d0940/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "8d355298ca23",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"80/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HTTPD_PREFIX=/usr/local/apache2",
"HTTPD_VERSION=2.4.46",
"HTTPD_SHA256=740eddf6e1c641992b22359cabc66e6325868c3c5e2e3f98faf349b61ecf41ea",
"HTTPD_PATCHES="
],
"Cmd": [
"httpd-foreground"
],
"Image": "my_httpd_20201110_01",
"Volumes": null,
"WorkingDir": "/usr/local/apache2",
"Entrypoint": null,
"OnBuild": null,
"Labels": {},
"StopSignal": "SIGWINCH"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "c42182308254d8ccab1067f69058f1031e48d96f73e61211d94bf65a29c93bae",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
"SandboxKey": "/var/run/docker/netns/c42182308254",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "2c23e292ca725d5d92cb96577e533e9bac2712d282ca71d6977ed09f9c2fc6c3",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "bb9ef3fea98518fc6ec4c68ee009093ccdfe400f7d2b3226adec1ad94f10b062",
"EndpointID": "2c23e292ca725d5d92cb96577e533e9bac2712d282ca71d6977ed09f9c2fc6c3",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
httpd起動時と/bin/bash起動時で、inspectの差分を確認した。
セッションに関わる項目以外で、CmdとPathのみが異なっている。
起動時に実行されるコマンドは以下の項目で得られる様である。
他にも、Entrypointで指定する方法もある様だ。
table:docker run時の起動コマンド?
Path Cmd
コマンドラインオプションで指定しない場合 httpd-foreground httpd-foreground
コマンドラインオプション/bin/bashの場合 /bin/bash /bin/bash
code:inspect.diff
--- httpd.inspect.txt 2020-11-10 14:45:33.476965406 +0900
+++ bash.inspect.txt 2020-11-10 14:46:06.492568715 +0900
@@ -1,8 +1,8 @@
[
{
- "Id": "28ae475e90a8b90681e8ebee22954e731594d4d927e1fbad66bc5c67579f343b",
- "Created": "2020-11-10T05:44:50.677756151Z",
- "Path": "httpd-foreground",
+ "Id": "51138203744dd6b81b78e969802c909d66d3a14910111b5036c81ed2f81538d0",
+ "Created": "2020-11-10T05:45:42.159152496Z",
+ "Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
@@ -11,18 +11,18 @@
"Restarting": false,
"OOMKilled": false,
"Dead": false,
- "Pid": 17264,
+ "Pid": 17796,
"ExitCode": 0,
"Error": "",
- "StartedAt": "2020-11-10T05:44:51.487397802Z",
+ "StartedAt": "2020-11-10T05:45:43.048135742Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:ea0cef820e00a6d935c9b1f731030877054c054f3098c24a6ff30875780f585e",
- "ResolvConfPath": "/var/lib/docker/containers/28ae475e90a8b90681e8ebee22954e731594d4d927e1fbad66bc5c67579f343b/resolv.conf",
- "HostnamePath": "/var/lib/docker/containers/28ae475e90a8b90681e8ebee22954e731594d4d927e1fbad66bc5c67579f343b/hostname",
- "HostsPath": "/var/lib/docker/containers/28ae475e90a8b90681e8ebee22954e731594d4d927e1fbad66bc5c67579f343b/hosts",
- "LogPath": "/var/lib/docker/containers/28ae475e90a8b90681e8ebee22954e731594d4d927e1fbad66bc5c67579f343b/28ae475e90a8b90681e8ebee22954e731594d4d927e1fbad66bc5c67579f343b-json.log",
- "Name": "/jolly_ganguly",
+ "ResolvConfPath": "/var/lib/docker/containers/51138203744dd6b81b78e969802c909d66d3a14910111b5036c81ed2f81538d0/resolv.conf",
+ "HostnamePath": "/var/lib/docker/containers/51138203744dd6b81b78e969802c909d66d3a14910111b5036c81ed2f81538d0/hostname",
+ "HostsPath": "/var/lib/docker/containers/51138203744dd6b81b78e969802c909d66d3a14910111b5036c81ed2f81538d0/hosts",
+ "LogPath": "/var/lib/docker/containers/51138203744dd6b81b78e969802c909d66d3a14910111b5036c81ed2f81538d0/51138203744dd6b81b78e969802c909d66d3a14910111b5036c81ed2f81538d0-json.log",
+ "Name": "/fervent_chandrasekhar",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
@@ -125,16 +125,16 @@
},
"GraphDriver": {
"Data": {
- "LowerDir": "/var/lib/docker/overlay2/ee47ddc078b5c11e6467213b465cc15695909780b3c8851a435e1a3a029db75b-init/diff:/var/lib/docker/overlay2/d844ed406f251e7e341b5d1aca9f629e9f39d08d9ecc2578a6635df4bab79ecd/diff:/var/lib/docker/overlay
2/7856653887edd2dd1ba876e02cb80dc6fa73ed989fed9bd7f7341358c14b220b/diff:/var/lib/docker/overlay2/384fad5da2e64e97444d5f20e5ac5c4d6da16437a8cf1a7e44d3df7e94e97fa9/diff:/var/lib/docker/overlay2/4e171e79ec9425a550179cf0c4bdf949c064e6f6290d1367400dba0c
efcfd43e/diff:/var/lib/docker/overlay2/85a61fd1b2a161abb0edc16a482420ac115f09036b3e90cbf6d7db364a5066d6/diff:/var/lib/docker/overlay2/e8f9404bab50021f0232d6d04b1300410cc7e55ac2806203de3f36ea7b64ddea/diff",
- "MergedDir": "/var/lib/docker/overlay2/ee47ddc078b5c11e6467213b465cc15695909780b3c8851a435e1a3a029db75b/merged",
- "UpperDir": "/var/lib/docker/overlay2/ee47ddc078b5c11e6467213b465cc15695909780b3c8851a435e1a3a029db75b/diff",
- "WorkDir": "/var/lib/docker/overlay2/ee47ddc078b5c11e6467213b465cc15695909780b3c8851a435e1a3a029db75b/work"
+ "LowerDir": "/var/lib/docker/overlay2/3261c5cf85398b22c60e5d1664f0d5bd179bf49698f776fdfd8a9e613f12505e-init/diff:/var/lib/docker/overlay2/d844ed406f251e7e341b5d1aca9f629e9f39d08d9ecc2578a6635df4bab79ecd/diff:/var/lib/docker/overlay
2/7856653887edd2dd1ba876e02cb80dc6fa73ed989fed9bd7f7341358c14b220b/diff:/var/lib/docker/overlay2/384fad5da2e64e97444d5f20e5ac5c4d6da16437a8cf1a7e44d3df7e94e97fa9/diff:/var/lib/docker/overlay2/4e171e79ec9425a550179cf0c4bdf949c064e6f6290d1367400dba0c
efcfd43e/diff:/var/lib/docker/overlay2/85a61fd1b2a161abb0edc16a482420ac115f09036b3e90cbf6d7db364a5066d6/diff:/var/lib/docker/overlay2/e8f9404bab50021f0232d6d04b1300410cc7e55ac2806203de3f36ea7b64ddea/diff",
+ "MergedDir": "/var/lib/docker/overlay2/3261c5cf85398b22c60e5d1664f0d5bd179bf49698f776fdfd8a9e613f12505e/merged",
+ "UpperDir": "/var/lib/docker/overlay2/3261c5cf85398b22c60e5d1664f0d5bd179bf49698f776fdfd8a9e613f12505e/diff",
+ "WorkDir": "/var/lib/docker/overlay2/3261c5cf85398b22c60e5d1664f0d5bd179bf49698f776fdfd8a9e613f12505e/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
- "Hostname": "28ae475e90a8",
+ "Hostname": "51138203744d",
"Domainname": "",
"User": "",
"AttachStdin": true,
@@ -154,7 +154,7 @@
"HTTPD_PATCHES="
],
"Cmd": [
- "httpd-foreground"
+ "/bin/bash"
],
"Image": "my_httpd_20201110_01",
"Volumes": null,
@@ -166,17 +166,17 @@
},
"NetworkSettings": {
"Bridge": "",
- "SandboxID": "bffa82a07a91d6d5125bf0faed5b43e19abdaa01ce76094c0efb1c6a06988e12",
+ "SandboxID": "dabc89cef10c9647dd2d8e11c0f51e8be33cb154b1ef3ecd54e527f6bfc3f3c2",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"80/tcp": null
},
- "SandboxKey": "/var/run/docker/netns/bffa82a07a91",
+ "SandboxKey": "/var/run/docker/netns/dabc89cef10c",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
- "EndpointID": "5e49c0a838b431913d4730f2ccc6126144677cc9c843824023f3e7de8c08cd13",
+ "EndpointID": "b748299b04b54125a4ba8172b1242ccfb0d442ed27d942ce81d681af8de1f68c",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
@@ -190,7 +190,7 @@
"Links": null,
"Aliases": null,
"NetworkID": "bb9ef3fea98518fc6ec4c68ee009093ccdfe400f7d2b3226adec1ad94f10b062",
- "EndpointID": "5e49c0a838b431913d4730f2ccc6126144677cc9c843824023f3e7de8c08cd13",
+ "EndpointID": "b748299b04b54125a4ba8172b1242ccfb0d442ed27d942ce81d681af8de1f68c",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,