Docker 上安装 centos 7.x ,然后安装桌面环境及vncserver远程查询国外网站.
1. Docker 上安装 centos 7.x
1 2 3 | docker run --name centos7 -it --privileged=true -d -e "container=docker" -p 8071:22 -p 8064:22 -p 8074:80 -p 8084:443 -p 8094:5901 ansible/centos7-ansible /usr/sbin/init docker ps -a docker exec -it centos7 /bin/bash |
2. 进入docker ,把yum 源换成阿里云源,然后就可以 yum install **** 安装软件了.
1 2 | docker ps -a //查看已经创建的容器 docker exec -it centos7 /bin/bash //进入容器 |
修改 CentOS-Base.repo 配置
1 | vi /etc/yum.repos.d/CentOS-Base.repo |
换成如下阿里云源
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | [base] name=CentOS-$releasever - Base - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-$releasever - Updates - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/ gpgcheck=1 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 |
然后就可以更新软件了
1 | yum update -y |
3. 设置密码及开启密码访问
默认并没有安装 openssh-server
1 | yum install -y openssh-server |
修改配置
1 | vi /etc/ssh/sshd_config |
1 2 3 | LoginGraceTime 2m //#去掉,改为600m PermitRootLogin yes //#去掉 StrictModes yes //#去掉 |
设置root密码
1 | passwd root |
重启sshd
1 | systemctl restart sshd.service |
4. 以后都通过ssh进入
1 | ssh root@172.17.0.2 |
5. 安装vncserver
1 | https://zls.bndstone.com/1658.html |
6. 安装Google Chrome
1 | https://zls.bndstone.com/4746.html |
6-1. 下载124版本
1 | wget https://linuxsoft.bndstone.com/chrome/google-chrome-stable-124.0.6367.118-1.x86_64.rpm |
6-2. 安装
1 | yum localinstall -y google-chrome-stable-124.0.6367.118-1.x86_64.rpm |
6-3. 从安全角度来看,chrome 是不应该在root用户权限下运行的,如果真的想在root下运行需要使用 –no-sandbox 来运行
1 | vi /bin/google-chrome |
1 | exec -a "$0" "$HERE/chrome" "$@" 找到这行, 将其注释掉 |
并添加一行
1 | exec -a "$0" "$HERE/chrome" "$@" --user-data-dir --no-sandbox |
6-4. 重启
1 | reboot |