您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息

Docker下部署MySQL和Wordpress

2019/9/12 11:29:16发布89次查看

docker下部署mysql和wordpress
检查当前系统版本,docker要求centos必须是64位7版本以上才可以:
1.[root@localhost ~]# cat /etc/redhat-release
2.centos linux release 7.6.1810 (core)
检查内核版本,docker支持内核3.10版本以上:
1.[root@localhost ~]#uname -r
2.3.10.0-957.el7.x86_64
安装docker
1.[root@localhost ~]# yum install -y docker
为了加快docker的下载速度,我们一般从国内镜像站点下载。修改镜像服务器
打开配置文件
1.[root@localhost ~]#cd /etc/docker
2.[root@localhost docker]# vi daemon.json
修改配置文件内容,此处选择阿里云的镜像站点:
1.{
2.registry-mirrors: [wordpress the wordpress rich content management syst... 10
10.docker.io docker.io/appsvcorg/wordpress-alpine-php this is a wordpress docker ... 7
11.docker.io docker.io/bitnami/wordpress-nginx bitnami docker image for wordpress with nginx 7 [ok]
搜索获得“好评 stars”超过的5个的记录(这个参数的用法已经被废止,不建议使用了)
1.[root@localhost docker]# docker search wordpress -s 5
2.flag --stars has been deprecated, use --filter=stars=3 instead
3.index name description stars official automated
4.docker.io docker.io/wordpress the wordpress rich content management syst... 3068 [ok]
5.docker.io docker.io/bitnami/wordpress bitnami docker image for wordpress 116 [ok]
6.docker.io docker.io/tutum/wordpress out-of-the-box wordpress docker image 35
7.docker.io docker.io/appcontainers/wordpress centos/debian based ... 34 [ok]
8.docker.io docker.io/aveltens/wordpress-backup easily backup and... 16 [ok]
9.docker.io docker.io/centurylink/wordpress wordpress image with mysql removed. 14 [ok]
10.docker.io docker.io/arm32v7/wordpress the wordpress rich content management syst... 10
11.docker.io docker.io/appsvcorg/wordpress-alpine-php this is a wordpress doc... 7
12.docker.io docker.io/bitnami/wordpress-nginx bitnami docker image for wordpress with nginx 7 [ok]
13.docker.io docker.io/dalareo/wordpress-ldap wordpress images with ldap support automat... 6 [ok]
也可以使用最新的参数进行过滤搜索,搜索星数量超过100的镜像:
1.[root@localhost docker]#docker search wordpress --filter=stars=100
2.index name description stars official automated
3.docker.io docker.io/wordpress the wordpress rich content management syst... 3068 [ok]
4.docker.io docker.io/bitnami/wordpress bitnami docker image for wordpress 116 [ok]
拉取第一个最新版本的wordpriss
1.[root@localhost docker]# docker pull wordpress
2.。。。。。
3.7e4ee285d305: pull complete
4.digest: sha256:6566a68d0c613304aa11255d98aba6e29c5fa8cd8497064639343956a4c7d2b1
5.status: downloaded newer image for docker.io/wordpress:latest
拉取最新版的mysql
1.[root@localhost docker]# docker pull mysql
2.using default tag: latest
3.trying to pull repository docker.io/library/mysql ...
4.latest: pulling from docker.io/library/
5.。。。。。。。
6.digest: sha256:01cf53f2538aa805bda591d83f107c394adca8d31f98eacd3654e282dada3193
7.status: downloaded newer image for docker.io/mysql:latest
查看当前容器列表,已经出现我们拉取的两个镜像文件了:
1.[root@localhost docker]# docker images
2.repository tag image id created size
3.docker.io/wordpress latest 5040cbf30a44 2 days ago 502 mb
4.docker.io/mysql latest 62a9f311b99c 3 days ago 445 mb
5.[root@localhost docker]#
创建并运行mysql容器
1.[root@localhost /]# docker run -d --privileged=true -p 3306:3306 --name wpmysql -v /data/mysql:/var/lib/mysql -e mysql_root_password=1111 mysql
2.cd13f4311f8e14511eba7d124a0a3a17a4ee553ccdfb4b45770535396c035256
3.[root@localhost /]#
docker run-d
--privileged=true 使container内的root拥有真正的root权限
-p 3306:3306 将主机和容器之间进行端口映射
--name wpmysql 为容器起名
-v /data/mysql:/var/lib/mysql 将mysql挂载到本地主机
-e mysql_root_password=1111 设置mysql数据库root用户的密码
mysql
检查容器运行情况,可以看到新运行的mysql容器
1.[root@localhost /]# docker ps
2.container id image command created status ports names
3.cd13f4311f8e mysql docker-entrypoint... 2 minutes ago up about a minute 0.0.0.0:3306->3306/tcp, 33060/tcp wpmysql
4.[root@localhost /]#
创建并运行wordpress容器
1.[root@localhost /]# docker run -d --name mywp -e wordpress_db_host=mysql -e wordpress_db_password=1111 -p 80:80 --link wpmysql:mysql wordpress
2.32ad7252ec8e7d0b3fd6abd8a8c4883f2cccdb4480f2994c14ee05b7b8f2dc76
docker run -d
--name mywp 设置容器名称
-e wordpress_db_password=1111 设置访问数据库的密码
-p 80:80 在主机和容器间进行端口映射
--link wpmysql:mysql 连接到mysq容器
wordpress
查看当前运行的容器列表
1.[root@localhost /]# docker ps
2.container id image command created status ports names
3.32ad7252ec8e wordpress docker-entrypoint... 2 minutes ago up 2 minutes 0.0.0.0:80->80/tcp mywp
4.cd13f4311f8e mysql docker-entrypoint... 12 minutes ago up 12 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp wpmysql
查看当前ip地址
1.[root@localhost /]#ifconfig
2.ens33: flags=4163 mtu 1500
3.inet 192.168.1.33 netmask 255.255.255.0 broadcast 192.168.1.255
4.inet6 fe80::e1b8:d032:218:5143 prefixlen 64 scopeid 0x20
5.ether 00:0c:29:2f:e3:aa txqueuelen 1000 (ethernet)
6.rx packets 493392 bytes 712587368 (679.5 mib)
7.rx errors 0 dropped 0 overruns 0 frame 0
8.tx packets 303935 bytes 22880279 (21.8 mib)
9.tx errors 0 dropped 0 overruns 0 carrier 0 collisions 0
打开浏览器访问地址:
1.wp-admin/install.php
停止mysql容器:
1.[root@localhost mysql]# docker stop wpmysql wpmysql
删除mysql容器:
1.[root@localhost mysql]# docker rm wpmysql wpmysql

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录