「Docker コマンド」の版間の差分
ナビゲーションに移動
検索に移動
23行目: | 23行目: | ||
| docker pull nginx:latest | | docker pull nginx:latest | ||
|- | |- | ||
− | ! scope="row"| docker run -i | + | ! scope="row"| docker run -i |
− | | | + | | インタラクティブ実行 |
| docker run -i -t -h ubuntu ubuntu /bin/bash | | docker run -i -t -h ubuntu ubuntu /bin/bash | ||
|- | |- | ||
− | ! scope="row"| docker | + | ! scope="row"| docker run -d |
− | | | + | | バックグラウンド実行 |
− | | | + | | docker run --name test-nginx -d nginx -p 8080:80 nginx |
|- | |- | ||
! scope="row"| docker | ! scope="row"| docker |
2020年10月2日 (金) 07:06時点における版
目次
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 | ||
docker | ||
docker | ||
docker | ||
docker | ||
docker |
バージョンの確認(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 矢木浩人