docker-端口映射
1.端口映射
-默认容器是可以通过SNAT访问外网,但是外部网络无法访问容器内的资源
-使用端口映射可以实现外部网络访问容器内的资源
docker run -itd -v /webroot:/var/www/html -p 80:80 centos
把容器封装起来通过端口映射达到对外部提供服务的目的,可以封装web服务,数据库服务等等,想用的时候直接调用就行,和语言中的面向对象思想相像
When nothing seems to help, I go look at a stonecutter hammering away at his rock, perhaps a hundred times without as much as a crack showing in it. Yet at the hundred and first blow it will split in two, and I know it was not that blow that did it, but all that had gone before. -- Jacob Riis