「Docker コマンド」の版間の差分
ナビゲーションに移動
検索に移動
(→コマンド) |
|||
| (同じ利用者による、間の14版が非表示) | |||
| 1行目: | 1行目: | ||
| − | ==Docker コマンド== | + | | [[Docker]] | [[WSL]] | [[Kubernetes]] |
| − | [[Docker]] | [[仮想化]] | | + | ==[[Docker コマンド]]== |
| + | | [[Docker]] | [[仮想化]] | [[Kubernetes]] | | ||
{{amazon|B00JWM4W2E}} | {{amazon|B00JWM4W2E}} | ||
*http://typea.info/blg/glob/2014/08/docker-commands.html | *http://typea.info/blg/glob/2014/08/docker-commands.html | ||
| + | ===コマンド=== | ||
| + | {| class="wikitable" | ||
| + | |- | ||
| + | ! scope="col"| コマンド | ||
| + | ! scope="col"| 内容 | ||
| + | ! scope="col"| 例 | ||
| + | |- | ||
| + | ! scope="row"| docker version | ||
| + | | バージョンの確認 | ||
| + | | | ||
| + | |- | ||
| + | ! scope="row"| docker info | ||
| + | | 現在の情報 | ||
| + | | | ||
| + | |- | ||
| + | ! scope="row"| docker pull [NAME:TAG] | ||
| + | | イメージの取得 | ||
| + | | docker pull nginx:latest | ||
| + | |- | ||
| + | ! scope="row"| docker run -i | ||
| + | | インタラクティブ実行 | ||
| + | | docker run -i -t -h ubuntu ubuntu /bin/bash | ||
| + | |- | ||
| + | ! scope="row"| docker run -d | ||
| + | | バックグラウンド実行 | ||
| + | | docker run --name test-nginx -d nginx -p 8080:80 nginx | ||
| + | |- | ||
| + | ! scope="row"| docker stop [コンテナID] | ||
| + | | コンテナの停止 | ||
| + | | docker stop 5fe904cacaff | ||
| + | |- | ||
| + | ! scope="row"| docker start [コンテナID] | ||
| + | | コンテナが残っている場合、再実行できる | ||
| + | | docker start 5fe904cacaff | ||
| + | |- | ||
| + | ! scope="row"| docker exec | ||
| + | | 実行しているコンテナのコマンドを実行 | ||
| + | | docker exec -it 5fe904cacaff bash | ||
| + | |- | ||
| + | ! scope="row"| docker inspect | ||
| + | | オブジェクトのインスペクト(ipアドレスを調べるなど) | ||
| + | | docker inspect 5fe | ||
| + | |- | ||
| + | ! scope="row"| docker | ||
| + | | | ||
| + | |- | ||
| + | ! scope="row"| docker | ||
| + | | | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | ===runコマンドオプション=== | ||
| + | {| class="wikitable" | ||
| + | |- | ||
| + | ! scope="col"| コマンドオプション | ||
| + | ! scope="col"| パラメータ | ||
| + | ! scope="col"| 内容 | ||
| + | ! scope="col"| 例 | ||
| + | |- | ||
| + | ! scope="row"| -p, --publish | ||
| + | | hostPort:containerPort | ||
| + | | コンテナポートをホストに公開 | ||
| + | | docker run --name test-ginx -d -p 8080:80 nginx | ||
| + | |- | ||
| + | ! scope="row"| -v, --volume | ||
| + | | /host:/container | ||
| + | | ボリュームをバインド | ||
| + | | docker run --name bind-eginx -d -p 8080:80 -v /mnt/c/workspaces/docker/
nginx/content:/usr/share/nginx/html:ro nginx | ||
| + | |} | ||
===バージョンの確認(version)=== | ===バージョンの確認(version)=== | ||
| 10行目: | 80行目: | ||
Client API version: 1.12 | Client API version: 1.12 | ||
Go version (client): go1.2.2 | Go version (client): go1.2.2 | ||
| − | Git commit (client): 63fe64c/1.0.0 | + | [[Git]] commit (client): 63fe64c/1.0.0 |
Server version: 1.0.0 | Server version: 1.0.0 | ||
Server API version: 1.12 | Server API version: 1.12 | ||
Go version (server): go1.2.2 | Go version (server): go1.2.2 | ||
| − | Git commit (server): 63fe64c/1.0.0 | + | [[Git]] commit (server): 63fe64c/1.0.0 |
===情報の確認(info)=== | ===情報の確認(info)=== | ||
# docker info | # docker info | ||
Containers: 1 | Containers: 1 | ||
Images: 3 | Images: 3 | ||
| − | Storage Driver: | + | Storage Driver: de[[vi]]cemapper |
Pool Name: docker-253:1-203234686-pool | Pool Name: docker-253:1-203234686-pool | ||
| − | Data file: /var/lib/docker/ | + | Data file: /var/lib/docker/de[[vi]]cemapper/de[[vi]]cemapper/data |
| − | Metadata file: /var/lib/docker/ | + | Metadata file: /var/lib/docker/de[[vi]]cemapper/de[[vi]]cemapper/metadata |
Data Space Used: 569.2 Mb | Data Space Used: 569.2 Mb | ||
Data Space Total: 102400.0 Mb | Data Space Total: 102400.0 Mb | ||
| 30行目: | 100行目: | ||
Kernel Version: 3.10.0-123.el7.x86_64 | Kernel Version: 3.10.0-123.el7.x86_64 | ||
===イメージの取得=== | ===イメージの取得=== | ||
| − | ====Docker Registry==== | + | ====[[Docker]] Registry==== |
*https://registry.hub.docker.com/ | *https://registry.hub.docker.com/ | ||
===取得(pull)=== | ===取得(pull)=== | ||
| 43行目: | 113行目: | ||
===確認(images)=== | ===確認(images)=== | ||
# docker images | # docker images | ||
| − | + | [[R]]EPOSITO[[R]]Y TAG IMAGE ID C[[R]]EATED VI[[R]]TUAL SIZE | |
openshift/wildfly-8-centos latest f3ba582d4042 6 days ago 539.3 MB | openshift/wildfly-8-centos latest f3ba582d4042 6 days ago 539.3 MB | ||
centos latest 1a7dc42f78ba 8 days ago 236.4 MB | centos latest 1a7dc42f78ba 8 days ago 236.4 MB | ||
| 58行目: | 128行目: | ||
====プロセスの確認(ps)==== | ====プロセスの確認(ps)==== | ||
# docker ps | # docker ps | ||
| − | CONTAINER ID IMAGE | + | CONTAINER ID IMAGE [[COM]]MAND CREATED STATUS PORTS NAMES |
564e5343046f openshift/wildfly-8-centos:latest /wildfly/bin/standal About a minute ago Up About a minute 7600/tcp, 8080/tcp, 9990/tcp, 9999/tcp insane_euclid | 564e5343046f openshift/wildfly-8-centos:latest /wildfly/bin/standal About a minute ago Up About a minute 7600/tcp, 8080/tcp, 9990/tcp, 9999/tcp insane_euclid | ||
====プロセス監視(top)==== | ====プロセス監視(top)==== | ||
| 77行目: | 147行目: | ||
====イメージの削除(rmi)==== | ====イメージの削除(rmi)==== | ||
# docker images | # docker images | ||
| − | + | [[R]]EPOSITO[[R]]Y TAG IMAGE ID C[[R]]EATED VI[[R]]TUAL SIZE | |
openshift/wildfly-8-centos latest f3ba582d4042 3 weeks ago 539.3 MB | openshift/wildfly-8-centos latest f3ba582d4042 3 weeks ago 539.3 MB | ||
<none> <none> 1a7dc42f78ba 3 weeks ago 236.4 MB | <none> <none> 1a7dc42f78ba 3 weeks ago 236.4 MB | ||
| 100行目: | 170行目: | ||
"HOME=/", | "HOME=/", | ||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", | "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", | ||
| − | " | + | "STI_SC[[R]]IPTS_U[[R]]L=https://raw.githubusercontent.com/openshift/wildfly-8-centos/master/.sti/bin" |
], | ], | ||
"ExposedPorts": { | "ExposedPorts": { | ||
| 123行目: | 193行目: | ||
}, | }, | ||
"Created": "2014-08-03T14:37:58.975398521Z", | "Created": "2014-08-03T14:37:58.975398521Z", | ||
| − | "Driver": " | + | "Driver": "de[[vi]]cemapper", |
"ExecDriver": "native-0.2", | "ExecDriver": "native-0.2", | ||
"HostConfig": { | "HostConfig": { | ||
| 139行目: | 209行目: | ||
"9999/tcp": null | "9999/tcp": null | ||
}, | }, | ||
| − | " | + | "Pri[[vi]]leged": false, |
"PublishAllPorts": false, | "PublishAllPorts": false, | ||
"VolumesFrom": null | "VolumesFrom": null | ||
| 147行目: | 217行目: | ||
"Id": "faff5b7c749257ff79180b5c9b90e3cadabec91a76895c086ec4e66fd84b3733", | "Id": "faff5b7c749257ff79180b5c9b90e3cadabec91a76895c086ec4e66fd84b3733", | ||
"Image": "f3ba582d4042e5e506e787e102bd122617cf4d574a32ff75ec5c5606aa60c4f0", | "Image": "f3ba582d4042e5e506e787e102bd122617cf4d574a32ff75ec5c5606aa60c4f0", | ||
| − | "MountLabel": "system_u:object_r: | + | "MountLabel": "system_u:object_r:s[[vi]]rt_sandbox_file_t:s0:c219,c329", |
"Name": "/compassionate_babbage", | "Name": "/compassionate_babbage", | ||
"NetworkSettings": { | "NetworkSettings": { | ||
| 163行目: | 233行目: | ||
}, | }, | ||
"Path": "/wildfly/bin/standalone.sh", | "Path": "/wildfly/bin/standalone.sh", | ||
| − | "ProcessLabel": "system_u:system_r: | + | "ProcessLabel": "system_u:system_r:s[[vi]]rt_lxc_net_t:s0:c219,c329", |
| − | " | + | "[[R]]esolvConfPath": "/etc/resolv.conf", |
"State": { | "State": { | ||
"ExitCode": 0, | "ExitCode": 0, | ||
| 170行目: | 240行目: | ||
"Paused": false, | "Paused": false, | ||
"Pid": 3503, | "Pid": 3503, | ||
| − | " | + | "[[R]]unning": true, |
"StartedAt": "2014-08-19T14:00:08.994894748Z" | "StartedAt": "2014-08-19T14:00:08.994894748Z" | ||
}, | }, | ||
"Volumes": {}, | "Volumes": {}, | ||
| − | " | + | "Volumes[[R]]W": {} |
} | } | ||
] | ] | ||
2020年10月3日 (土) 04:27時点における最新版
| Docker | WSL | Kubernetes
目次
Docker コマンド
| Docker | 仮想化 | Kubernetes |
コマンド
| コマンド | 内容 | 例 |
|---|---|---|
| docker version | バージョンの確認 | |
| docker info | 現在の情報 | |
| docker pull [NAME:TAG] | イメージの取得 | docker pull nginx:latest |
| docker run -i | インタラクティブ実行 | docker run -i -t -h ubuntu ubuntu /bin/bash |
| docker run -d | バックグラウンド実行 | docker run --name test-nginx -d nginx -p 8080:80 nginx |
| docker stop [コンテナID] | コンテナの停止 | docker stop 5fe904cacaff |
| docker start [コンテナID] | コンテナが残っている場合、再実行できる | docker start 5fe904cacaff |
| docker exec | 実行しているコンテナのコマンドを実行 | docker exec -it 5fe904cacaff bash |
| docker inspect | オブジェクトのインスペクト(ipアドレスを調べるなど) | docker inspect 5fe |
| docker | ||
| docker |
runコマンドオプション
| コマンドオプション | パラメータ | 内容 | 例 |
|---|---|---|---|
| -p, --publish | hostPort:containerPort | コンテナポートをホストに公開 | docker run --name test-ginx -d -p 8080:80 nginx |
| -v, --volume | /host:/container | ボリュームをバインド | docker run --name bind-eginx -d -p 8080:80 -v /mnt/c/workspaces/docker/ nginx/content:/usr/share/nginx/html:ro nginx |
バージョンの確認(version)
# docker version Client version: 1.0.0 Client API version: 1.12 Go version (client): go1.2.2 Git commit (client): 63fe64c/1.0.0 Server version: 1.0.0 Server API version: 1.12 Go version (server): go1.2.2 Git commit (server): 63fe64c/1.0.0
情報の確認(info)
# docker info Containers: 1 Images: 3 Storage Driver: devicemapper Pool Name: docker-253:1-203234686-pool Data file: /var/lib/docker/devicemapper/devicemapper/data Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata Data Space Used: 569.2 Mb Data Space Total: 102400.0 Mb Metadata Space Used: 0.9 Mb Metadata Space Total: 2048.0 Mb Execution Driver: native-0.2 Kernel Version: 3.10.0-123.el7.x86_64
イメージの取得
Docker Registry
取得(pull)
# docker pull openshift/wildfly-8-centos
Pulling repository openshift/wildfly-8-centos
f3ba582d4042: Download complete
f3ba582d4042: Pulling image (latest) from openshift/wildfly-8-centos
511136ea3c5a: Download complete
:
7e1fd6711692: Download complete
6244d7d2948c: Download complete
確認(images)
# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE openshift/wildfly-8-centos latest f3ba582d4042 6 days ago 539.3 MB centos latest 1a7dc42f78ba 8 days ago 236.4 MB
実行
インタラクティブ実行(run –t)
- run –t でインタラクティブにシェルを実行出来る
- 任意のコマンドをコンテナ内で実行可能
- 停止する場合は、Ctrl+D
# docker run -i -t -h openshift/wildfly-8-centos openshift/wildfly-8-centos /bin/bash bash-4.1#
バックグラウンド実行(run –d)
# docker run -d openshift/wildfly-8-centos /wildfly/bin/standalone.sh 564e5343046f97da12ba09273020eabbb7a84d4b0299f13c256b43aa449d1bb7
プロセスの確認(ps)
# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 564e5343046f openshift/wildfly-8-centos:latest /wildfly/bin/standal About a minute ago Up About a minute 7600/tcp, 8080/tcp, 9990/tcp, 9999/tcp insane_euclid
プロセス監視(top)
# docker top 564e5343046f UID PID PPID C STIME TTY TIME CMD root 5739 1401 0 23:22 ? 00:00:00 /bin/sh /wildfly/bin/standalone.sh root 5867 5739 14 23:22 ? 00:00:07 java -D[Standalone] -server -XX:+UseSerialGC -Xms40m -Xmx256m -XX:MaxPermSize=102m -XX:+AggressiveOpts -Dorg.apache.tomcat.util.LOW_MEMORY=true -DOPENSHIFT_APP_UUID= -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Dorg.jboss.resolver.warning=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -Djboss.node.name=564e5343046f -Djgroups.bind_addr=0.0.0.0 -Dorg.apache.coyote.http11.Http11Protocol.COMPRESSION=on -Dorg.jboss.boot.log.file=/wildfly/standalone/log/server.log -Dlogging.configuration=file:/wildfly/standalone/configuration/logging.properties -jar /wildfly/jboss-modules.jar -mp /wildfly/provided_m
コンテナの停止(stop)
# docker stop 564e5343046f 564e5343046f
コンテナの強制終了(kill)
# docker kill faff5b7c7492 faff5b7c7492
コンテナの再起動(restart)
# docker restart 564e5343046f 564e5343046f
イメージの管理
イメージの削除(rmi)
# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE openshift/wildfly-8-centos latest f3ba582d4042 3 weeks ago 539.3 MB <none> <none> 1a7dc42f78ba 3 weeks ago 236.4 MB # docker rmi -f 1a7dc42f78ba Deleted: 1a7dc42f78ba213ec1ac5cd04930011334536214ad26c8000f1eec72e302c041
コンテナ状態の確認(inspect)
# docker inspect faff5b7c7492
[{
"Args": [],
"Config": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": [
"/wildfly/bin/standalone.sh"
],
"CpuShares": 0,
"Cpuset": "",
"Domainname": "",
"Entrypoint": null,
"Env": [
"HOME=/",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"STI_SCRIPTS_URL=https://raw.githubusercontent.com/openshift/wildfly-8-centos/master/.sti/bin"
],
"ExposedPorts": {
"7600/tcp": {},
"8080/tcp": {},
"9990/tcp": {},
"9999/tcp": {}
},
"Hostname": "faff5b7c7492",
"Image": "openshift/wildfly-8-centos",
"Memory": 0,
"MemorySwap": 0,
"NetworkDisabled": false,
"OnBuild": null,
"OpenStdin": false,
"PortSpecs": null,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": null,
"WorkingDir": "/opt/wildfly/source"
},
"Created": "2014-08-03T14:37:58.975398521Z",
"Driver": "devicemapper",
"ExecDriver": "native-0.2",
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"Dns": null,
"DnsSearch": null,
"Links": null,
"LxcConf": [],
"NetworkMode": "bridge",
"PortBindings": {
"7600/tcp": null,
"8080/tcp": null,
"9990/tcp": null,
"9999/tcp": null
},
"Privileged": false,
"PublishAllPorts": false,
"VolumesFrom": null
},
"HostnamePath": "/var/lib/docker/containers/faff5b7c749257ff79180b5c9b90e3cadabec91a76895c086ec4e66fd84b3733/hostname",
"HostsPath": "/var/lib/docker/containers/faff5b7c749257ff79180b5c9b90e3cadabec91a76895c086ec4e66fd84b3733/hosts",
"Id": "faff5b7c749257ff79180b5c9b90e3cadabec91a76895c086ec4e66fd84b3733",
"Image": "f3ba582d4042e5e506e787e102bd122617cf4d574a32ff75ec5c5606aa60c4f0",
"MountLabel": "system_u:object_r:svirt_sandbox_file_t:s0:c219,c329",
"Name": "/compassionate_babbage",
"NetworkSettings": {
"Bridge": "docker0",
"Gateway": "172.17.42.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"PortMapping": null,
"Ports": {
"7600/tcp": null,
"8080/tcp": null,
"9990/tcp": null,
"9999/tcp": null
}
},
"Path": "/wildfly/bin/standalone.sh",
"ProcessLabel": "system_u:system_r:svirt_lxc_net_t:s0:c219,c329",
"ResolvConfPath": "/etc/resolv.conf",
"State": {
"ExitCode": 0,
"FinishedAt": "2014-08-19T13:58:30.659032186Z",
"Paused": false,
"Pid": 3503,
"Running": true,
"StartedAt": "2014-08-19T14:00:08.994894748Z"
},
"Volumes": {},
"VolumesRW": {}
}
]
© 2006 矢木浩人