在Docker中安装宝塔面板

安装宝塔

sudo docker pull centos:centos7 #centos:centos8 centos:latest #下载centos镜像
sudo docker run -i -t -d --name baota --net=host --restart=always \
  --privileged=true -v /home/www:/www centos:centos7
sudo docker exec -it baota /bin/bash #进入容器系统
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh #正常安装宝塔

注意:为了能够保存(持久化)数据以及共享容器间的数据,docker一定使用-v挂载主机目录到容器,比如上面启动容器的 docker -v 参数。
宝塔默认密码使用 : bt default 查看,登录进去修改即可

Docker安装

  • Ubuntu
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo tee /etc/apt/sources.list.d/docker.list <<-'EOF'
"deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu focal stable"
EOF
sudo apt update
sudo apt -y install docker-ce
  • centos
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
sudo yum makecache fast
sudo yum -y install docker-ce

修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
    "registry-mirrors": [
        "https://lna3sr3v.mirror.aliyuncs.com",
        "https://kfwkfulq.mirror.aliyuncs.com",
        "https://2lqq34jg.mirror.aliyuncs.com",
        "https://pee6w651.mirror.aliyuncs.com",
        "https://registry.docker-cn.com",
        "http://hub-mirror.c.163.com"
    ],
    "dns": [
        "8.8.8.8",
        "8.8.4.4"
    ]
}
EOF
# 重新加载配置或重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
posted @ 2021-10-07 18:04  至尊王者  阅读(993)  评论(0编辑  收藏  举报