Docker Basic
安装 docker
- 二进制格式
tar -xf /usr/local/src/docker/docker-19.03..tgz
cd docker/
mv * /usr/bin/
mkdir /etc/docker
vi /etc/docker/daemon.json
dockerd & - yum 包
yum install epel-release
yum install docker-iocentos-6
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl status docker
docker -vcentos-7
默认关闭了【nightly or test】在 docker-ce.repo 中:
yum-config-manager --enable docker-ce-nightly
yum-config-manager --enable docker-ce-test
yum-config-manager --disable docker-ce-nightly
yum-config-manager --disable docker-ce-test指定确定的版本来安装
yum list docker-ce --showduplicates | sort -r
yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io 阿里安装
# step : 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step : 添加软件源信息
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step : 更新并安装Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step : 开启Docker服务
sudo service docker start # 注意:
# 官方软件源默认启用了最新的软件,您可以通过编辑软件源的方式获取各个版本的软件包。例如官方并没有将测试版本的软件源置为可用,您可以通过以下方式开启。同理可以开启各种测试版本等。
# vim /etc/yum.repos.d/docker-ee.repo
# 将[docker-ce-test]下方的enabled=0修改为enabled=
#
# 安装指定版本的Docker-CE:
# Step : 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
# Loading mirror speeds from cached hostfile
# Loaded plugins: branch, fastestmirror, langpacks
# docker-ce.x86_64 17.03..ce-.el7.centos docker-ce-stable
# docker-ce.x86_64 17.03..ce-.el7.centos @docker-ce-stable
# docker-ce.x86_64 17.03..ce-.el7.centos docker-ce-stable
# Available Packages
# Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.-.el7.centos)
# sudo yum -y install docker-ce-[VERSION]- 服务管理
systemctl start docker
systemctl stop dockeryum
- 镜像加速
{
"registry-mirrors": ["http://hub-mirror.c.163.com","https://registry.docker-cn.com","https://mirror.ccs.tencentyun.com"]
}daemon.json
重新配置镜像信息,重启一下
#这里操作,等同于登录到本地内建虚拟机执行编辑配置的操作
docker-machine ssh default
sudo vi /var/lib/boot2docker/profile
# --registry-mirror http://hub-mirror.c.163.com
exit
docker-machine restart default
# 检查添加
docker infowindows 环境下【DockerToolbox】
- 卸载
卸载 7 的 yumyum remove docker-ce docker-ce-cli containerd.io
# $ du -sh /var/lib/docker
# .2G /var/lib/docker
rm -rf /var/lib/docker
镜像操作常用命令
- 检索
docker search 关键字 - 拉取
docker pull 镜像名称[:tag]
tag 表示版本信息,默认是 latest - 本地镜像
docker images - 删除本地镜像
docker rmi IMAGE-ID
容器操作命令
# 创建容器
docker run -d [--name 容器名] 镜像名[:tag]
#停止容器:
docker stop [容器名|CONTAINER-ID]
#启动容器:
docker start [容器名|CONTAINER-ID] #查看容器
#查看运行中的容器:
docker ps
#查看所有的现有容器:
docker ps -a #删除容器
docker rm [容器名|CONTAINER-ID] #端口映射
docker run -d -p : [--name 容器名] [镜像名:tag] #查看容器日志
docker logs [CONTAINER-ID|容器名]基本操作
# 启动容器
docker run -d --name myTomcat tomcat: # 启动容器并且映射端口到本地监听的 (默认tcp)
docker run -d -p : --name myTomcat2 tomcat:启动一个 tomcat 容器
#交互式启动容器
docker run -it --name myCent centos:
# ctro + p + q 退出容器保持运行,exit 退出并关闭容器交互式启动一个 linux 容器
# 这是一个正在运行的 tomcat8
$ docker inspect 39692a4836cd
[
{
"Id": "39692a4836cdb733d4e23e25a0ca8cef1db3680b05c951e50d9489cebf9ed3c4",
"Created": "2020-05-11T02:31:15.904851059Z",
"Path": "catalina.sh",
"Args": [
"run"
],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": ,
"ExitCode": ,
"Error": "",
"StartedAt": "2020-05-11T02:31:17.861972617Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:eb2cfb95e04d8afcdb65c770cd44d9d003836d53fb780e33d3a6f8c5f7d80def",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/39692a4836cdb733d4e23e25a0ca8cef1db3680b05c951e50d9489cebf9ed3c4/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/39692a4836cdb733d4e23e25a0ca8cef1db3680b05c951e50d9489cebf9ed3c4/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/39692a4836cdb733d4e23e25a0ca8cef1db3680b05c951e50d9489cebf9ed3c4/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/39692a4836cdb733d4e23e25a0ca8cef1db3680b05c951e50d9489cebf9ed3c4/39692a4836cdb733d4e23e25a0ca8cef1db3680b05c951e50d9489cebf9ed3c4-json.log",
"Name": "/myTomcat3",
"RestartCount": ,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": ""
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount":
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": ,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": ,
"Runtime": "runc",
"ConsoleSize": [
, ],
"Isolation": "",
"CpuShares": ,
"Memory": ,
"NanoCpus": ,
"CgroupParent": "",
"BlkioWeight": ,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": ,
"CpuQuota": ,
"CpuRealtimePeriod": ,
"CpuRealtimeRuntime": ,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": ,
"KernelMemoryTCP": ,
"MemoryReservation": ,
"MemorySwap": ,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": ,
"CpuPercent": ,
"IOMaximumIOps": ,
"IOMaximumBandwidth": ,
"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": "/mnt/sda1/var/lib/docker/overlay2/573c6ae1ee7ed0dddf45564c370c7961965ed39959133e6054b9f51ef5e2d78d-init/diff:/mnt/sda1/var/lib/docker/overlay2/939f7b6cffd167550cbc81d068e60e4a2248031194af3a67ca414eece44260ce/diff:/mnt/sda1/var/lib/docker/overlay2/9e6b65a77e9708516171c5f1195c38d45bea35d4eac7a57202531cc664e94dc6/diff:/mnt/sda1/var/lib/docker/overlay2/c9d0aa7a535d312d95df270d65da969d3650b1ad7dc45bb8c085615164a19c83/diff:/mnt/sda1/var/lib/docker/overlay2/5e8ea3fd89d8b142a2ac440f9fb1866ec6966923057a4d825de3a56a43395a80/diff:/mnt/sda1/var/lib/docker/overlay2/7461dce2b458b7096a62e37c7e57ad3051304e68c573efb57154ff3cc9485efc/diff:/mnt/sda1/var/lib/docker/overlay2/68ee55f7ed04a00750ba39e7ed7c4e3695bfe096efcd10eba1a06a5630ba6b68/diff:/mnt/sda1/var/lib/docker/overlay2/3014a59c9e34aca0f583a5c6c6cfff7326639f55212c96d635d3bc2089724c17/diff:/mnt/sda1/var/lib/docker/overlay2/f1155ae8f0ac20d42c102d09c22b053009458bc6b1d1860dee52040bfecd0ad7/diff:/mnt/sda1/var/lib/docker/overlay2/4e32c8dc9eb7bdaecb59828563e605e65b6819d027ca2623e781db8f06d7ec69/diff:/mnt/sda1/var/lib/docker/overlay2/29b6619ec6af0f8394005bd262084ce8c3786d8cdd80aedccca7b1a5fa224edc/diff",
"MergedDir": "/mnt/sda1/var/lib/docker/overlay2/573c6ae1ee7ed0dddf45564c370c7961965ed39959133e6054b9f51ef5e2d78d/merged",
"UpperDir": "/mnt/sda1/var/lib/docker/overlay2/573c6ae1ee7ed0dddf45564c370c7961965ed39959133e6054b9f51ef5e2d78d/diff",
"WorkDir": "/mnt/sda1/var/lib/docker/overlay2/573c6ae1ee7ed0dddf45564c370c7961965ed39959133e6054b9f51ef5e2d78d/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "39692a4836cd",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/tomcat/bin:/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"JAVA_HOME=/usr/local/openjdk-8",
"JAVA_VERSION=8u252",
"JAVA_BASE_URL=https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u252-b09/OpenJDK8U-jdk_",
"JAVA_URL_VERSION=8u252b09",
"CATALINA_HOME=/usr/local/tomcat",
"TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
"LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
"GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 713DA88BE50911535FE716F5208B0AB1D63011C7 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23",
"TOMCAT_MAJOR=8",
"TOMCAT_VERSION=8.5.54",
"TOMCAT_SHA512=dc3ba0183d1e6f6006e5430e91abbc0758bdb719efebea5809f7034c9a28c590a764d8fcf2528a27a98cb86531e94cd9dc5a92cdbcae36e808ced0e5f1c665b8"
],
"Cmd": [
"catalina.sh",
"run"
],
"Image": "tomcat:8",
"Volumes": null,
"WorkingDir": "/usr/local/tomcat",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "6ece37fc03f190194c839f484b5c1a01509f4efaf07594c0e87a58708d80d720",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": ,
"Ports": {
"8080/tcp": [
{
"HostIp": "127.0.0.1",
"HostPort": ""
}
]
},
"SandboxKey": "/var/run/docker/netns/6ece37fc03f1",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "9cf56b0928db163280fa129a0eb03dd5a857d3bccff09f95328d8fb1c5838ede",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": ,
"IPAddress": "172.17.0.4",
"IPPrefixLen": ,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:04",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "d6a260f49e8de56f2b0cc2b2fad20bd921565525f4e54034d17eed669b596dc4",
"EndpointID": "9cf56b0928db163280fa129a0eb03dd5a857d3bccff09f95328d8fb1c5838ede",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": ,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": ,
"MacAddress": "02:42:ac:11:00:04",
"DriverOpts": null
}
}
}
}
] # 这是一个停止运行的 tomcat9
$ docker inspect 9435318c06ca
[
{
"Id": "9435318c06cac456ae99efbb78af5ee132512d4e57ef6b64884ed3b247d2eb49",
"Created": "2020-05-09T03:05:44.952681404Z",
"Path": "catalina.sh",
"Args": [
"run"
],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": ,
"ExitCode": ,
"Error": "",
"StartedAt": "2020-05-09T03:05:47.484205141Z",
"FinishedAt": "2020-05-09T03:07:33.953054485Z"
},
"Image": "sha256:927899a31456255c1e1a73b97d9a94451c4fcffedab4e0cf18b1c6c4fe4b84ff",
"ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/9435318c06cac456ae99efbb78af5ee132512d4e57ef6b64884ed3b247d2eb49/resolv.conf",
"HostnamePath": "/mnt/sda1/var/lib/docker/containers/9435318c06cac456ae99efbb78af5ee132512d4e57ef6b64884ed3b247d2eb49/hostname",
"HostsPath": "/mnt/sda1/var/lib/docker/containers/9435318c06cac456ae99efbb78af5ee132512d4e57ef6b64884ed3b247d2eb49/hosts",
"LogPath": "/mnt/sda1/var/lib/docker/containers/9435318c06cac456ae99efbb78af5ee132512d4e57ef6b64884ed3b247d2eb49/9435318c06cac456ae99efbb78af5ee132512d4e57ef6b64884ed3b247d2eb49-json.log",
"Name": "/beautiful_brahmagupta",
"RestartCount": ,
"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":
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "shareable",
"Cgroup": "",
"Links": null,
"OomScoreAdj": ,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"UTSMode": "",
"UsernsMode": "",
"ShmSize": ,
"Runtime": "runc",
"ConsoleSize": [
, ],
"Isolation": "",
"CpuShares": ,
"Memory": ,
"NanoCpus": ,
"CgroupParent": "",
"BlkioWeight": ,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": ,
"CpuQuota": ,
"CpuRealtimePeriod": ,
"CpuRealtimeRuntime": ,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": ,
"KernelMemoryTCP": ,
"MemoryReservation": ,
"MemorySwap": ,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": ,
"CpuPercent": ,
"IOMaximumIOps": ,
"IOMaximumBandwidth": ,
"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": "/mnt/sda1/var/lib/docker/overlay2/d1022de2348d9daa174152acab00a8d4b181a9579fbec8c08cbeaeeda023f529-init/diff:/mnt/sda1/var/lib/docker/overlay2/ae1036a63ca9ba4f7f24311b4a98742542a4a0c623db4a36844c269ff0925ca3/diff:/mnt/sda1/var/lib/docker/overlay2/1cb5cd1038068be5f38b9d916b7e8f34349cb4267c25cea1979bebdd2bd5b4fc/diff:/mnt/sda1/var/lib/docker/overlay2/826902e7bb7426b34ae37cc0e5e7ccaec71a635ad6376325f5e6cdade3673b27/diff:/mnt/sda1/var/lib/docker/overlay2/2af0b175306258e8346f19a844e42334120c8fcd5fbb6acd90ea11faab3c4472/diff:/mnt/sda1/var/lib/docker/overlay2/f7b556e3bfdcbe8dfb81e0c87f20d7ccbc6a65aa023887a32158b8758e3213c5/diff:/mnt/sda1/var/lib/docker/overlay2/68ee55f7ed04a00750ba39e7ed7c4e3695bfe096efcd10eba1a06a5630ba6b68/diff:/mnt/sda1/var/lib/docker/overlay2/3014a59c9e34aca0f583a5c6c6cfff7326639f55212c96d635d3bc2089724c17/diff:/mnt/sda1/var/lib/docker/overlay2/f1155ae8f0ac20d42c102d09c22b053009458bc6b1d1860dee52040bfecd0ad7/diff:/mnt/sda1/var/lib/docker/overlay2/4e32c8dc9eb7bdaecb59828563e605e65b6819d027ca2623e781db8f06d7ec69/diff:/mnt/sda1/var/lib/docker/overlay2/29b6619ec6af0f8394005bd262084ce8c3786d8cdd80aedccca7b1a5fa224edc/diff",
"MergedDir": "/mnt/sda1/var/lib/docker/overlay2/d1022de2348d9daa174152acab00a8d4b181a9579fbec8c08cbeaeeda023f529/merged",
"UpperDir": "/mnt/sda1/var/lib/docker/overlay2/d1022de2348d9daa174152acab00a8d4b181a9579fbec8c08cbeaeeda023f529/diff",
"WorkDir": "/mnt/sda1/var/lib/docker/overlay2/d1022de2348d9daa174152acab00a8d4b181a9579fbec8c08cbeaeeda023f529/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "9435318c06ca",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"ExposedPorts": {
"8080/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": [
"PATH=/usr/local/tomcat/bin:/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"LANG=C.UTF-8",
"JAVA_HOME=/usr/local/openjdk-11",
"JAVA_VERSION=11.0.7",
"JAVA_BASE_URL=https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_",
"JAVA_URL_VERSION=11.0.7_10",
"CATALINA_HOME=/usr/local/tomcat",
"TOMCAT_NATIVE_LIBDIR=/usr/local/tomcat/native-jni-lib",
"LD_LIBRARY_PATH=/usr/local/tomcat/native-jni-lib",
"GPG_KEYS=05AB33110949707C93A279E3D3EFE6B686867BA6 07E48665A34DCAFAE522E5E6266191C37C037D42 47309207D818FFD8DCD3F83F1931D684307A10A5 541FBE7D8F78B25E055DDEE13C370389288584E7 61B832AC2F1C5A90F0F9B00A1C506407564C17A3 79F7026C690BAA50B92CD8B66A3AD3F4F22C4FED 9BA44C2621385CB966EBA586F72C284D731FABEE A27677289986DB50844682F8ACB77FC2E86E29AC A9C5DF4D22E99998D9875A5110C01C5A2F6059E7 DCFD35E0BF8CA7344752DE8B6FB21E8933C60243 F3A04C595DB5B6A5F1ECA43E3B7BBB100D811BBE F7DA48BB64BCB84ECBA7EE6935CD23C10D498E23",
"TOMCAT_MAJOR=9",
"TOMCAT_VERSION=9.0.34",
"TOMCAT_SHA512=9cb32f8807c0e8d2457d52ac032bb496ae7921e1ea0a0c8e6082bf8da60bb57c317a3f2376589962123dd803fdd2816ff960339cb851d9859b2241165fbc278e"
],
"Cmd": [
"catalina.sh",
"run"
],
"Image": "tomcat",
"Volumes": null,
"WorkingDir": "/usr/local/tomcat",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "7223237e6487cd1bed261dc47e0dfdd0860fbba55c1aea97bdb105f1de9aeb01",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": ,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/7223237e6487",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": ,
"IPAddress": "",
"IPPrefixLen": ,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "cddf9f45df5a57ba7491b78441ebe65bb91c8b1a84c32d9ae1d055b9975eed65",
"EndpointID": "",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": ,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": ,
"MacAddress": "",
"DriverOpts": null
}
}
}
}
]查看容器内部细节
- 操纵容器
# 指定【容器id】、或者【容器名称】
docker attach myCent
docker attach de04fcc86f00返回容器 attach
docker exec myCent w
docker exec myCent ps -ef
docker exec myCent ip ad li # 通过 exec 实现 attach 返回容器的效果
docker exec -t myCent /bin/bash执行 容器内部命令 exec
创建新的镜像
docker CONTAINER docker CONTAINER [REPOSITORY[:TAG]] docker commit [-m "Commit message"] [-a "author string"] CONTAINER [REPOSITORY[:TAG]]
创建新镜像语法
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
de04fcc86f00 centos: "/bin/bash" hours ago Up About an hour myCent # 从容器开始,创建我自己的【新镜像】
$ docker commit -m "我自己创建的镜像" -a "argor" de04fcc86f00 argor_centos:
sha256:caa90c434aef5c4503abc6f0627fa6d4ad1456c94f86e6c6b688fa9a08bad556 $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
argor_centos caa90c434aef seconds ago 237MB
centos b5b4d78bc90c days ago 203MB
centos 470671670cac months ago 237MB
centos latest 470671670cac months ago 237MB创建容器实例
容器数据卷
#默认就是 rw
docker run -it -v /data01:/data01 centos # ro
docker run -it -v /data02:/data02:ro centos命令行方式创建
$ cat mydocker/dockerfile
FROM centos
VOLUME ["/DATA01","/DATA02","/DATA03"]
CMD echo "docker said that welcome argor."
CMD /bin/bash $ docker build -f mydocker/dockerfile -t argor/centos: . $ docker images argor/centos
REPOSITORY TAG IMAGE ID CREATED SIZE
argor/centos 67716c343a7b minutes ago 203MB $ docker run -it 67716c343a7b /bin/bash [root@b09f60a15446 /]# ls /
DATA01 DATA02 DATA03 anaconda-post.log bin dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var使用dockersfile创建一个新的镜像
- 数据卷容器
docker run -it --name wonderful_swirles argor/demo
docker run -it --name again --volumes-from wonderful_swirles argor/demovolumes-from
Docker .
Docker Basic的更多相关文章
- 自制docker basic image
docker的安装和入门见官网教程:http://docs.docker.com/ 下面是自制docker basic image的步骤,以ubuntu为例. 1. 安装debootstrap apt ...
- Docker Day1 & 2
1. Docker Basic 安装docker(在/etc/selinux/config文件中设置selinux=disabled,否则安装时会报错) curl -ssL http://get.do ...
- vagrant特性——基于docker开发环境(docker和vagrant的结合)-1-基本使用
Docker vagrant提供了使用Docker作为provider(其他的provider有virtualBox.VMware\hyper-V等)的开箱即用支持.这允许你的开发环境由Docker容 ...
- docker开发_在basic image的基础上创建自定义的image
方法一:docker commit 1. 跑一个basic image,docker新建了一个容器 root@ubuntu:/home/thm/docker/test# docker run -i - ...
- Basic concepts of docker/kubernete/kata-container
Kubereters An open-source system for automating deployment, scaling, and management of containerized ...
- 【kubernetes secret 和 aws ecr helper】kubernetes从docker拉取image,kubernetes docker私服认证(argo docker私服认证),no basic auth credentials错误解决
aws ecr helper: https://aws.amazon.com/blogs/compute/authenticating-amazon-ecr-repositories-for-dock ...
- MySQL、MongoDB、Redis数据库Docker镜像制作
MySQL.MongoDB.Redis数据库Docker镜像制作 在多台主机上进行数据库部署时,如果使用传统的MySQL的交互式的安装方式将会重复很多遍.如果做成镜像,那么我们只需要make once ...
- 【云计算】docker三剑客如何支持分布式部署?
This blog will explain how to create multi-container application deployed on multiple hosts using Do ...
- Install Docker on Mac OS X(转)
Install Docker on Mac OS X You can install Docker using Boot2Docker to run docker commands at your c ...
随机推荐
- Android 单元测试实践
1. 在Android Studio创建工程 工程名称 AndroidUnitTest 2. 创建测试类CommonUtil 在类中加入sum和multiply方法 在CommonUtil类中右击 ...
- mysql 主从复制change master to
CHANGE MASTER TO命令用于slave配置连接master的信息,例如master host.master port等. 关于CHANGE MASTER TO命令,总结几点使用心得. 在C ...
- Go语言加解密--AES简单实践
AES加解密的简单实现,代码如下. package main import ( "crypto/aes" "crypto/cipher" "encod ...
- RedHat7.3安装MySQL5.7
1.下载Mysql安装包 https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.20-1.el6.x86_64.rpm-bundle.tar 附百度 ...
- 基于mysql对mybatis中的foreach进行深入研究
鉴于上一篇博文一次修改mysql字段类型引发的技术探究提到的,要对foreach里面的collection相关的内容做一些介绍,今天就围绕foreach,做一些数据插入和查询相关的研究. 首先介绍一下 ...
- openwrt挂载摄像头及视频保存
一.编译选项的选择: -> Utilities ->usbutils (这个里面包含lsusb的命令,是查看你的摄像头型号的) -> Kernel modules -> I2C ...
- SPI 核软件调试记录
SPI 核软件调试记录 1.首先说说int SpiFlashWaitForFlashReady(void)这一函数,基本上其它函数在执行的时候,都会事先执行一次此函数. 因为此函数的作用主要是用 ...
- Excel技巧--使用规划求解
当我们需要求在有限预算下可以购买的商品数量时,我们就可以使用“规划求解”功能.如上图,在1000元的预算目标内,我们能购买左图中的各书籍多少本.而这些数量,就可以使用“规划求解”来获取答案. 1.实际 ...
- g++编译后中文显示乱码解决方案(c++)
g++编译后中文显示乱码解决方案 环境:Windows 10 专业版 GCC版本:5.3.0 测试代码: 1 #include <iostream> 2 using namespace ...
- 使用Selenium模拟浏览器抓取淘宝商品美食信息
代码: import re from selenium import webdriver from selenium.webdriver.common.by import By from seleni ...