Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
docker 安装宝塔面板 bt-panel – 扎老铁
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
class="post-53348 post type-post status-publish format-standard hentry">

docker 安装宝塔面板 bt-panel

baota-paner 宝塔面板

dockerHub: https://hub.docker.com/r/chenzhuoqi/baota/

How to run

docker run --rm -d -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 -v $PWD/www:/www  centos7.2-98617c88 bash /bootstrap.sh
# or
docker-compose up -d

How to visit

url:http://yourip:8888
username:admin
password:64b0dfc8

How to persist data

www 目录是宝塔初始化需要的目录,将其挂载到容器里面,数据持久化


自定义安装 How to build

此镜像是是基于centos,run起来,安装宝塔面板,commit成的镜像

run centos镜像

# 宿主机
# 创建一个docker容器让他后台运行,然后将真机的20,21,80,443,888,8888这五个端口映射到docker容器中去
# 将真机的 $PWD/www 文件夹映射到docker容器的/www上
docker run -i -t -d -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 -v $PWD/www:/www centos

***  2018/2/5 宝塔最新版(5.5.0)测试: 安装提示无权限,需要去掉 -v $PWD/www:/www 

# 查看当前生成的容器id
docker ps

# 进入docker
docker exec -it XXXXX bash

安装宝塔面板

# 容器
yum install -y initscripts
# 安装宝塔
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh


安装完了就可以看到账户名密码

Bt-Panel: http://xxxxxx:8888
username: admin
password: XXXXXX

*** 2018/2/5 宝塔最新版(5.5.0)测试:然后会宝塔提供的 ip 无法访问,改用 http://localhost:8888 可以访问

停止宝塔服务,添加docker的启动脚本

service bt stop
# 更新www权限,不然不能拷贝文件
chmod -R 766 /www
# 增加启动脚本,sleep 10000000000000000000000000000000 是为了让docker容器一直活着
echo 'service bt start && sleep 10000000000000000000000000000000' > /bootstrap.sh
# 给启动脚本添加执行权限
chmod +x /bootstrap.sh

commit成镜像

# 将面板的初始数据共享出来,启动的时候再挂载进去
docker cp XXX(containerId):/www .
# commit镜像
docker commit XXX(containerId) baota:XXXXXX(password)

======

You can commit your existing container (that is create a new image from container’s changes) and then run it with your new mounts.

Example:

$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a8f89adeead ubuntu:14.04 “/bin/bash” About a minute ago Exited (0) About a minute ago agitated_newton

$ docker commit 5a8f89adeead newimagename

$ docker run -ti -v “$PWD/dir1”:/dir1 -v “$PWD/dir2”:/dir2 newimagename /bin/bash
If it’s all OK, stop your old container, and use this new one.

That´s it 🙂

https://stackoverflow.com/questions/28302178/how-can-i-add-a-volume-to-an-existing-docker-container

安装启动后,宝塔默认不会自动运行
输入 bt start 即可
另外,mysql 也需要手动在宝塔面板中启动!

发表评论

电子邮件地址不会被公开。