上一篇,我们讲到如何去安装Docker,在这一篇中,我们将继续来进行Docker实验,Docker是一个可以提供应用隔离环境的容器技术,应用的产生来源于一个个容器,那么容器是如何来的呢?今天就来聊聊镜像的获取与创建容器。涉及的架构如下图所示:
1、今天我们实验将使用Wordpress来做实验,首先Wordpress在Docker镜像库上的网址是:index.docker.io,当然你可以通过命令行(也推荐使用命令行搜索)sudo docker search wordpress:
2、接着使用docker pull wordpress进行安装(这里的镜像名需要填完整名称):
3、这样,你就拥有了第一个容器,这个容器的类型是Wordpress,然而并不能马上使用,因为Wordpress需要结合Mysql来用,所以你还需要下载Mysql容器来做结合:
docker search mysql
docker pull mysql
4、Docker容器的概念有点像沙盒,这是一个非常duang的概念,可以利用镜像生成容器,每个容器相当于一个独立的环境,比如我们要搭建Wordpress,我们需要先启动一个Mysql的容器mysql_root_password是设置db密码(由于博主的虚拟机给的RAM太小,用原生的last版本的Mysql会提示RAM不足导致Mysql数据库无法正常运行,故这里重新pull了一个mysql 5.7):
docker run –name wordpressdb -e MYSQL_ROOT_PASSWORD=xxxx -d mysql5.7
5、容器在Linux上呈现为一个进程,任何的运行都在这个进程中执行,如果存在多个容器,它们之间也是隔离的,故安全性非常高,我们可以用docker ps查看下刚刚创建的db是否正常:
6、接着,我们就可以使用Wordpress结合Mysql了来搭建第一个容器,由于Wordpress需要php环境,我们运行docker run –name wordpress php:5.6-apache 来安装php依赖条件,然后再使用 docker run –name vmcloud_wordpress –link wordpressdb:mysql -p 3306:80 -d wordpress来运行一个WordPress容器(请注意一定要指定好端口 –p,这里是将容器内的80端口映射为3306,),然后我们再来docker ps看下进程:
7、然后做个portmap,输入对应的URL:3306,你就会发现惊喜:
8、我们再来看看运行了一个Mysql+Wordpress的容器占用主机大概多少资源:
Been messing around on rwin99 for a few days. I actually won a bit on their sports bets! The odds aren't always the best, but they cover a lot of different sports. If you like betting on sports, give rwin99 a shot.
I was worried about the login process but it was actually very straightforward. No glitches at all on unsur138login so far.
Very impressive selection of games and the local payment methods make everything so much easier. I am very satisfied with this service. vnneu88
Really impressed with the customer support here. They helped me sort out my account in minutes. idselayar88 is definitely my new favorite spot for gaming.
Great selection of live dealer games. It feels like I am actually in a real casino. I really enjoy the vibe at abcbet234.
Finally found a reliable place to get the app. The installation was a breeze and everything works perfectly on my phone. Big thanks to pkx666gamedownload for the quick setup.