docker 使用之网络和存储

一、docker的网络和存储

网络

 docker端口映射html

[root@zabbix ~]# docker run  -d -P nginx   
#-P 随机映射端口
#-p 指定端口映射 hostport:containerport ip:hostport:containerport
7be83a9a04772c48c06a6ae5ffb767042e1bf38ec6c0a4407b1035ad375b571f
[root@zabbix ~]# docker ps -l   #nginx的80端口映射到了32768端口
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                   NAMES
7be83a9a0477        nginx               "nginx -g 'daemon ..."   3 minutes ago       Up 3 minutes        0.0.0.0:32768->80/tcp   friendly_hugle

查看docker容器的日志nginx

[root@zabbix ~]# docker logs 7be83a9a0477
192.168.10.100 - - [15/Mar/2018:14:46:53 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36" "-"
192.168.10.100 - - [15/Mar/2018:14:46:53 +0000] "GET /favicon.ico HTTP/1.1" 404 571 "http://192.168.10.119:32768/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36" "-"
2018/03/15 14:46:53 [error] 5#5: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.10.100, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "192.168.10.119:32768", referrer: "http://192.168.10.119:32768/"

docker 存储

[root@7523e5d73d8f ~]# docker run --name centos -it -v /opt:/opt centos   #指定容器挂载到那个目录下

 指定容器挂载到另外一个容器的目录下docker

[root@zabbix opt]# docker run -d --name nfs -v /data centos 
 32b80ffd51d6f915d0c31b9201bf1861df19b29dc7492316488b6f7e309b0220
[root@zabbix opt]# docker run -it --name test --volumes-from nfs centos 
[root@e6d22b4a6fe0 /]#
posted @ 2020-12-15 11:19  拼拼有礼  阅读(153)  评论(0编辑  收藏  举报
我的小站: 投资理财 股票配资 刷Q币 赚钱技巧 问答平台

https://www.752520.com/sitemap-posttype-post.2020.xml

https://www.752520.com/sitemap.xml