日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

目錄
  • 1、基于DockerHub Centos鏡像
  • 2、 Centos鏡像存在的一個自身問題:啟動后的容器內部無法使用systemctl命令
  • 3、在基礎鏡像中安裝基礎服務
  •  4、在基礎鏡像中配置WebSSH
  • 5、后臺啟動并指定webssh服務的日志目錄
  •  6、加入開機自啟
  •  7、制作最終鏡像并在遷移后使用 
  •  8、頁面訪問

1、基于DockerHub Centos鏡像

docker pull centos:centos7

Docker配置WebSSH的實現

2、 Centos鏡像存在的一個自身問題:啟動后的容器內部無法使用systemctl命令

        Failed to get D-Bus connection: Operation not permitted

## docker run -dit eeb6ee3f44bd /bin/bash
## 切勿忘記宿主機防火墻開放8889 2200端口
docker run -dit -p 8889:8888 -p 2200:22 --restart=always --privileged --name t2 centos:centos7 init

3、在基礎鏡像中安裝基礎服務

(1)安裝sshd、httpd、firewalld服務

yum install -y openssh openssh-server openssh-client
yum install httpd
yum install firewalld firewall-config

(2) 啟動服務后并加入開機自啟

## 啟動
systemctl start sshd
systemctl start httpd
systemctl start firewalld
## 開機自啟
systemctl enable sshd
systemctl enable httpd
systemctl enable firewalld

(3)針對于httpd服務

localhost.localdomain httpd[1953]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

vi /etc/httpd/conf/httpd.conf 加入一句:ServerName localhost:80
systemctl restart httpd

(4)針對于firewalld服務

WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now

vi /etc/firewalld/firewalld.conf
AllowZoneDrifting=yes ====》》AllowZoneDrifting=no
systemctl restart firewalld

(5)開放端口

firewall-cmd --permanent --add-port=8888/tcp
firewall-cmd --reload
firewall-cmd --list-all

(6)設置默認初始密碼:passwd root

 4、在基礎鏡像中配置WebSSH

(1)安裝python3

yum install python3-pip

(2)安裝WebSSH

##### pip3 install webssh
##### pip3 報錯:Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-xxx/xxx/ 
##### https://www.modb.pro/db/81767

 針對以上報錯的解決方案:

### 升級setuptools
pip3 install --upgrade setuptools -i https://mirrors.aliyun.com/pypi/simple/
### 升級pip工具:https://www.cnblogs.com/rychh/p/16206842.html
pip3 --default-timeout=1000 install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/

 額外針對于以下告警的處理可選擇性處理:

### WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
### https://blog.csdn.net/m0_58782029/article/details/129049587

進行安裝:

pip3 --default-timeout=1000 install webssh -i https://mirrors.aliyun.com/pypi/simple/

5、后臺啟動并指定webssh服務的日志目錄

wssh --log-file-prefix=/data/webssh/wssh.log --timeout=500 --fbidhttp=false &

 6、加入開機自啟

vi /etc/rc.local
wssh --log-file-prefix=/data/webssh/wssh.log --timeout=500 --fbidhttp=false &
chmod 777 /etc/rc.local

 7、制作最終鏡像并在遷移后使用 

1、打包正在運行的容器為 image
docker commit eeb6ee3f44bd webssh:dev
2、保存image到文件
docker save -o webssh_dev.tar webssh:dev
3、使用已保存的image文件
docker load --input webssh_dev.tar

 8、頁面訪問

訪問方式(1)如圖:

Docker配置WebSSH的實現

 訪問方式(2)

## password需要進行base64加密
http://ip:8889?hostname=ip&username=root&password=cm9vdA==&port=2200

備注:

## 查看容器啟動日志
[vagrant@localhost images]$ sudo docker inspect --format '{{.LogPath}}' 21431ff039e7
/data/docker/containers/21431ff039e768753702d64cb01b1a75bb250c2c587b0f3396dd30b548a62850/21431ff039e768753702d64cb01b1a75bb250c2c587b0f3396dd30b548a62850-json.log

分享到:
標簽:Docker webssh 服務器 配置
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定