本文共 1666 字,大约阅读时间需要 5 分钟。
下载CentOS镜像
使用命令docker pull ansible/centos7-ansible
下载CentOS 7镜像。新建并运行镜像
创建一个新的Docker容器,名称为centos7baota
,并映射所需的端口:docker run -i -t -d --name centos7baota -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 --privileged=true ansible/centos7-ansible
这些端口包括80(HTTP)、443(HTTPS)、888(内网访问)、8888(宝塔面板默认端口)。
docker exec -it centos7baota /bin/bash
进入容器,安装宝塔面板:yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
在提示时输入y
继续安装。
配置镜像并提交
安装完成后,镜像地址会显示为http://60.169.128.90:8888/1e7aad20
,可以将其修改为http://localhost:8888/1e7aad20
。安装必要服务
在宝塔面板中安装nginx、php7.2和mysql5.6等服务,确保环境配置完成后再提交镜像。生成并运行新的镜像
使用docker commit -a "zq" -m "add baota" centos7baota ansible/centos7-ansible/bt
提交镜像,并根据新镜像ansible/centos7-ansible/bt
运行新的容器:docker run -i -t -d --name centos7-baota -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 -p 3306:3306 --privileged=true -v ~/Desktop/08-docker/01-www:/www/wwwroot -v ~/Desktop/08-docker/02-mysql:/www/server/data ansible/centos7-ansible/bt
docker exec -it c7bt /bin/bash /etc/init.d/bt restart
开启服务后,宝塔面板可通过http://localhost:8888/1e7aad20
访问。
xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp" xdebug.remote_host = host.docker.internal
这些设置允许PhpStorm通过XDebug进行远程调试,host.docker.internal
用于指定Docker容器的主机IP。
bd.test.com
(需在主机hosts
文件中添加相应记录)。/etc/hosts
文件,添加以下内容:sudo vim /etc/hosts
添加记录:
127.0.0.1 bd.test.com
转载地址:http://gvdwz.baihongyu.com/