查看所有容器
docker ps -a
宝塔Docker镜像制作
查看运行容器
docker ps
查看所有容器
docker ps -a
进入容器
其中字符串为容器ID:
docker exec -it d27bd3008ad9 /bin/bash
停用全部运行中的容器
docker stop $(docker ps -q)
删除全部容器:
docker rm $(docker ps -aq)
一条命令实现停用并删除容器
docker stop $(docker ps -q) & docker rm $(docker ps -aq)
安装宝塔
新建开放端口的容器
docker run –name srv -it -p 8888:8888 -p 80:80 -p 888:888 -p 443:443 -p ubuntu
升级apt
apt update
安装git,screen,sudo,wget,ping,tzdata等命令
apt install ….
wget -O install.sh http://download.bt.cn/install/install-ubuntu.sh && sudo bash install.sh
查看面板账户密码
service bt default
登录面板,修改账户密码为administrator,安装一系列软件
安装adminMongo
git clone https://github.com/mrvautin/adminMongo
修改root密码
passwd
安装ssh
apt install ssh
/etc/ssh/sshd_config 配置 PermitRootLogin 改为 yes
编写入口脚本,并执行stop(sh stop.sh)
#!/bin/sh # start bt services echo "Start bt services..." echo "start mongodb" service mongodb start echo "start adminMongo" pm2 start /www/adminMongo/app.js --name adminMongo echo "start mysqld" chown -R mysql:mysql /www/server/data service mysqld start echo "start redis" service redis start echo "start php" service php-fpm-56 start echo "start bt" service bt start echo "start ssh" service ssh start echo "run autorun.sh if exists" sh /autorun.sh echo "completed" tail -f /www/wwwlogs/access.log #!/bin/sh # stop bt services echo "Stop bt services..." echo "stop bt" service bt stop echo "stop pm2 apps" pm2 stop all echo "stop nginx" service nginx stop echo "stop mongodb" service mongodb stop echo "stop mysqld" service mysqld stop echo "stop php" service php-fpm-56 stop echo "stop redis" service redis stop echo "completed"
编写Dockerfile
FROM srv:latest USER root LABEL maintainer="yuri2peter@qq.com" EXPOSE 21 22 80 8888 888 443 1234
build 镜像
切换到Dockerfile文件所在目录
docker build -t srv .
运行镜像
docker run -itP srv:latest
设置默认站点main.com
PS
- pm2路径:/www/server/nvm/versions/node/v8.12.0/lib/node_modules/pm2/bin/pm2
- redis 需要配置项daemonize设置为yes防止接受ctrl+c退出
- KODE 不能访问文件夹?进入站点设置,关闭跨站攻击保护
本文摘自:https://wp.gxnas.com/2163.html,感谢原作者