好物优选点击查看详情 京东购买

暂无内容

docker-comepose编排工具部署mysql和wordpress

WordPress: 1. Create a new directory in your home folder called my_wordpress and cd into it: # mkdir wordpress # cd /wordpress 2. Create a file named docker-compose.yml in this folder and add the following contents. Set your own passwords for the WORDPRESS_DB_PASSWORD, MYSQL_ROOT_PASSWORD, and MYSQL_PASSWORD environment options. The password entered for WORDPRESS_DB_PASSWORD and MYSQL_PASSWORD should be the same. [root@localhost wordpress]# vim docker-compose.yml 复制以下内容,粘贴前必须关闭自动缩进 version: '3.3' services: wordpress: depends_on: - db image: wordpress:latest volumes: - wordpress_files:/var/www/html ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_NAME: wpdb WORDPRESS_DB_USER: wpuser WORDPRESS_DB_PASSWORD: wppass db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: luhao123 MYSQL_DATABASE: wpdb MYSQL_USER: wpuser MYSQL_PASSWORD: wppass volumes: wordpress_files: db_data: 3. 必须在该文件夹中启动 [root@localhost wordpress]#yum install -y docker-compose [root@localhost wordpress]#systemctl start docker [root@localhost wordpress]# docker pull wordpress:latest [root@localhost wordpress]# docker pull mysql:5.7 [root@localhost wordpress]# docker-compose up -d 

docker-comepose编排工具部署mysql和wordpress插图

 可能出现报错1 ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running? If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable. 解决办法: [root@] groupadd docker #创建docker组。 [root@] usermod -aG docker $(whoami) #将用户添加到docker组。 [root@] service docker restart # 重启docker 4. The Docker containers will take a minute or two to start up WordPress and MySQL. Afterwards, you can visit your IP address in your web browser and you should be directed to the WordPress setup form. [root@localhost wordpress]# iptables -t nat -vnL 可以看到8000端口为DNAT,ifconfig查看172地址,后面加:8000粘贴到浏览器 打开网页的8000端口即可看到wordpress已经部署好了 

docker-comepose编排工具部署mysql和wordpress插图1

原文链接:https://blog.csdn.net/weixin_43551152/article/details/86420669

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享