Docker Network Map
1, random mapping, random map of the port does not have a conflict-p
[Root@zabbix-3 ~]# Docker run-d-P--name mynginx1 nginx
ff5442b84da4b346e5470e3fc74c401ae14f7c3b3b72ad2d85ce04195f26976f
[Root@zabbix-3 ~]# Docker Ps-l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
FF5442B84DA4 nginx "nginx-g ' daemon off" 7 seconds ago up 5 seconds 0.0.0.0:32769-> ; 80/tcp, 0.0.0.0:32768->443/tcp mynginx1
[Root@zabbix-3 ~]#
2.-p Specify port Mappings
[Root@zabbix-3 ~]# Docker run-d-P 91:80--name mynginx2 Nginx
219c145ad549d11c50d611838063fa387ae174b436f8cc6d1edae997baa7a571
[Root@zabbix-3 ~]# Docker Ps-l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
219c145ad549 nginx "nginx-g ' daemon off" is seconds ago up 9 seconds 443/tcp, 0.0.0.0: 91->80/tcp Mynginx2
[Root@zabbix-3 ~]#
3.docker data storage, can refer to: http://dockone.io/article/128
Data volumes that can be bypassed to write data on a physical host
[Root@zabbix-3 ~]# Docker run-it--name volume-test1-h centos-v/data CentOS
[Root@centos/]# ls/data/
[Root@centos/]# LS/
Anaconda-post.log data etc Lib Lost+found mnt proc run SRV tmp var
Bin Dev Home lib64 media opt root sbin sys usr
[Root@centos/]#
[Root@zabbix-3 ~]# Docker run--name mark1-v/data-ti
[Root@fca3f6850e6a/]# ls-ld/data/
Drwxr-xr-x. 2 root root 6 June 09:45/data/
[Root@fca3f6850e6a/]# df-th
FileSystem Type Size Used Avail Use% mounted on
/dev/mapper/docker-253:0-68314296-da4f78f8af9a7c3e89ac958fcb9801e6ccc778fd3eda6ed1da4cb9503938a03d XFS 10G 241M 9.8G 3%/
Tmpfs tmpfs 1.9G 0 1.9G 0%/dev
Tmpfs tmpfs 1.9G 0 1.9G 0%/sys/fs/cgroup
/dev/mapper/centos-root XFS 18G 3.0G 15G 17%/data
SHM TMPFS 64M 0 64M 0%/DEV/SHM
[Root@fca3f6850e6a/]#
3.1 View Volume location
[root@zabbix-3 fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523]# Docker inspect Mark1|awk '/' Source "/{print $} '
"/var/lib/docker/volumes/ Fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523/_data ",
[root@zabbix-3 fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523]#
is as follows:
Mounts: [
{
' Name ': ' fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523 ",
"Source": "/var/lib/docker/volumes/fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523/_data ",
" destination ":"/data ",
"Driver": "Local",
"Mode": "",
"RW": True,
"propagation": "
}
],
/var/lib/docker/volumes/fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523/_ The data file, which is actually mapped in the container,
creates files on the OS, which in the container can be found to be almost identical
[Root@zabbix-3 _data]# cat/var/lib/docker/volumes/ Fce6e616518fb37c581a1a5b93247757ffae2dec861fc95bc3b3aae2ca53f523/_data/mark
Helo word!
[Root@zabbix-3 _data]#
View
[Root@zabbix-3 ~]#./in.sh mark1
[Root@fca3f6850e6a/]# ls/data/
Mark
[Root@fca3f6850e6a/]# Cat/data/mark
Helo word!
[Root@fca3f6850e6a/]#
3.2 Specify the directory to mount to the container:
Touch a file in opt and mount it in a container called Ott
[Root@zabbix-3 ~]# touch/opt/' date +%f-%t '. txt
[Root@zabbix-3 ~]#
Mount to container with colon spacing between/opt and/ott
[Root@zabbix-3 _data]# Docker run-it--name mark2-h nginx-v/opt:/ott CentOS
[Root@nginx/]# ll/ott/
Total 0
-rw-r--r--. 1 root root 0 June 13:36 2016-06-28-09:36:45.txt
[Root@nginx/]#
When the log of our container can also be stored on this computer, this mapping is not used on Docke file
If we mount read-only then we can add RO
Docker run-it--name mark2-h nginx-v/opt:/ott:ro
4. Mounting files
[Root@zabbix-3 ~]# Docker run-it--name mark3-h nginx-v/root/in.sh:/etc/in.sh CentOS
[Root@nginx/]# ll/etc/in.sh
-rwxr-xr-x. 1 root 134 June 17:59/etc/in.sh
[Root@nginx/]#
5.docker Data Volume container
Create a new container, the new container from the MARK1 container, the container share
[Root@zabbix-3 ~]# Docker run-it--name mark4--volumes-from mark1 CentOS
[Root@6cf741b2ef70/]# ls/data/
Mark
[Root@6cf741b2ef70/]#