行至水穷处 坐看“云”起时

Cloud Native ADN -> CNadn.Net

Docker学习备忘1

Centos7

[root@docker1 etc]# more system-release
CentOS Linux release 7.3.1611 (Core)
[root@docker1 etc]# uname -a
Linux docker1.f5lab.com 3.10.0-514.16.1.el7.x86_64 #1 SMP Wed Apr 12 15:04:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

[root@docker1 etc]# docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 17.05.0-ce
Storage Driver: overlay
Backing Filesystem: xfs
Supports d_type: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9048e5e50717ea4497b757314bad98ea3763c145
runc version: 9c2d8d184e5da67c95d601382adf14862e4f2228
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-514.16.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.844GiB
Name: docker1.f5lab.com
ID: 7DCC:YGQU:S2YZ:FYSL:4HMD:4GSC:5UCN:KIPQ:32QM:3TVC:YDJU:OUL6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

WARNING: overlay: the backing xfs filesystem is formatted without d_type support, which leads to incorrect behavior.
Reformat the filesystem with ftype=1 to enable d_type support.
Running without d_type support will not be supported in future releases.

刚启动docker后,/var/lib/docker下状态:


[root@docker1 docker]# tree -L 10
.
├── containers
├── image
│   └── overlay
│   ├── distribution
│   ├── imagedb
│   │   ├── content
│   │   │   └── sha256
│   │   └── metadata
│   │   └── sha256
│   ├── layerdb
│   └── repositories.json
├── network
│   └── files
│   └── local-kv.db
├── overlay
├── plugins
│   ├── storage
│   │   └── blobs
│   │   └── tmp
│   └── tmp
├── swarm
├── tmp
├── tmp-old
├── trust
└── volumes
└── metadata.db

23 directories, 3 files

 

[root@docker1 files]# pwd
/var/lib/docker/network/files

 

 

[root@docker1 files]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eno16777736
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736
[root@docker1 files]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:4e:be:c2:89 txqueuelen 0 (Ethernet)
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

eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.129 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::20c:29ff:fe42:d98 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:42:0d:98 txqueuelen 1000 (Ethernet)
RX packets 3444 bytes 467959 (456.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1817 bytes 600598 (586.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

eno33554960: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:0c:29:42:0d:a2 txqueuelen 1000 (Ethernet)
RX packets 7 bytes 1140 (1.1 KiB)
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

eno50332184: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 00:0c:29:42:0d:ac txqueuelen 1000 (Ethernet)
RX packets 7 bytes 1140 (1.1 KiB)
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

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 68 bytes 5844 (5.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 68 bytes 5844 (5.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

 

[root@docker1 files]# ip netns show 为空, 实际上此时是有ns的,只是容器的ns不在该命令查找的文件夹下。方法见学习备忘2文章

 

[root@docker1 files]# docker network ls
NETWORK ID NAME DRIVER SCOPE
734c4df7548e bridge bridge local
e7f32fd414b9 host host local
206ea33a6608 none null local
[root@docker1 files]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker1 files]# docker image
image images
[root@docker1 files]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@docker1 files]# docker volume ls
DRIVER VOLUME NAME

[root@docker1 files]# docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 0 0 0B 0B
Containers 0 0 0B 0B
Local Volumes 0 0 0B 0B


[root@docker1 files]# docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

 

[root@docker1 /]# docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
276041ef9cbe hello-world “/hello” 3 hours ago Exited (0) 3 hours ago agitated_keller

[root@docker1 files]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 48b5124b2768 3 months ago 1.84kB
[root@docker1 files]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 48b5124b2768 3 months ago 1.84kB

 

 

[root@docker1 files]# docker history hello-world
IMAGE CREATED CREATED BY SIZE COMMENT
48b5124b2768 3 months ago /bin/sh -c #(nop) CMD [“/hello”] 0B
<missing> 3 months ago /bin/sh -c #(nop) COPY file:22b680a46dca70… 1.84kB
[root@docker1 files]# docker inspect hello-world
[
{
“Id”: “sha256:48b5124b2768d2b917edcb640435044a97967015485e812545546cbed5cf0233”,
“RepoTags”: [
“hello-world:latest”
],
“RepoDigests”: [
“hello-world@sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7”
],
“Parent”: “”,
“Comment”: “”,
“Created”: “2017-01-13T22:50:56.415736637Z”,
“Container”: “d7e9f7ed9c135402fba7227d8da07c250126181eee0cfd2743b5736b80108625”,
“ContainerConfig”: {
“Hostname”: “b3e3b3843b7f”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“/bin/sh”,
“-c”,
“#(nop) “,
“CMD [\”/hello\”]”
],
“Image”: “sha256:fba45bbdabc1ff498b7965f99d2f25c59266cfa751067951f8e965841928c843”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {}
},
“DockerVersion”: “1.12.3”,
“Author”: “”,
“Config”: {
“Hostname”: “b3e3b3843b7f”,
“Domainname”: “”,
“User”: “”,
“AttachStdin”: false,
“AttachStdout”: false,
“AttachStderr”: false,
“Tty”: false,
“OpenStdin”: false,
“StdinOnce”: false,
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
],
“Cmd”: [
“/hello”
],
“Image”: “sha256:fba45bbdabc1ff498b7965f99d2f25c59266cfa751067951f8e965841928c843”,
“Volumes”: null,
“WorkingDir”: “”,
“Entrypoint”: null,
“OnBuild”: null,
“Labels”: {}
},
“Architecture”: “amd64”,
“Os”: “linux”,
“Size”: 1840,
“VirtualSize”: 1840,
“GraphDriver”: {
“Data”: {
“RootDir”: “/var/lib/docker/overlay/4ff8b86a0317b5a6bd539e51ec676395e6079f4d8a77b34ff95cb8a9451279a0/root”
},
“Name”: “overlay”
},
“RootFS”: {
“Type”: “layers”,
“Layers”: [
“sha256:98c944e98de8d35097100ff70a31083ec57704be0991a92c51700465e4544d08”
]
}
}
]

run一个镜像之后:

《Docker学习备忘1》

点赞