Mac环境 使用docker安装bt
2022年9月29日大约 2 分钟
Mac环境 使用docker安装bt
#安装centos
docker pull centos:centos7
#本地目录和容器映射目录
/Users/apple:/wwwroot
安装容器
任意端口
docker run -tid --net=host --name bt --entrypoint=init --privileged=true -v /Users/apple:/wwwroot centos
指定端口
docker run -tid -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p -p 8000-8100:8000-8100 -p 3306:3306 -p 6379:6379 --name bt --entrypoint=init --privileged=true -v /Users/apple:/wwwroot centos
查看容器id
docker ps -a
运行容器
docker exec -it bt /bin/bash
docker exec -it 0be4a7ea3b13 /bin/bash/init
进入yum的repos目录
cd /etc/yum.repos.d/
修改所有的CentOS文件内容
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum clean all && yum makecache
yum install -y wget
#修改密码
yum install passwd.x86_64 -y
passwd
#service安装
yum install initscripts -y
#ifconfig安装
yum install net-tools.x86_64 -y
#确认容器已开启sshd
rpm -qa | grep ssh
yum install openssh-server
#查看是否启动22端口
netstat -antp | grep sshd
#修改vi /etc/ssh/sshd_config 修改成密码登录 端口22,修改以下内容
PasswordAuthentication yes
AllowTcpForwarding yes
# 下面可以不管
PubkeyAuthentication yes #启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys #公钥文件路径(和上面生成的文件同)
PermitRootLogin yes #root能使用ssh登录 no禁止root账户使用ssh登录,这种设置通常用于互联网服务器,防止提权后用root账户登录搞破坏。
ClientAliveInterval 60 #参数数值是秒 , 是指超时时间
ClientAliveCountMax 3 #设置允许超时的次数
UsePAM yes 更改为 UsePAM no
Port 80 #指定好端口号,默认是22 后面这个数字要在你run容器的时候用到
#重启服务
systemctl restart sshd.service
安装宝塔
wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec
http://localhost:8888/e38c8700
username: jwoeqgjh
password: f4647ad1
## 启动停止
docker stop bt
docker restart bt
容器任意端口
docker run --net=host
给容器新增端口号
docker stop bt
复制一份容器
docker commit bt btt
启动新容器
docker run -tid -p 20:20 -p 21:21 -p 80:80 -p 443:443 -p 888:888 -p 8888:8888 -p 3306:3306 -p 6379:6379 -p 9502:9502 --name xxx --entrypoint=init --privileged=true -v /Users/apple:/wwwroot btt
docker run -tid --net=host --name xx --entrypoint=init --privileged=true -v /Users/apple:/wwwroot btt