ubuntu 創建容器 並ssh 連接容器


1.下載鏡像:docker search ubuntu 

docker pull ubuntu

2. 創建容器

docker run --name spider_frame -p 8888:8888 -p 10023:22 -it -d python:3.7 /bin/bash

3.進入容器docker exec -it spider_frame /bin/bash

4. 安裝:

安裝容器的openssh-server,輸入 apt-get install openssh-server -y

5.

成功安裝后,vim /etc/ssh/sshd_config,修改下面兩個配置

PermitRootLogin yes  
UsePAM no

6.

  1. 啟動ssh服務,service ssh start

  2. 退出容器,輸入exit,然后輸入docker ps -a,查看容器的ID

  3. 提交容器成為新的鏡像,例如叫做ubuntu-ssh,輸入docker commit 容器ID ubuntu-ssh

 7.設置ssh密碼:$ passwd root


Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

 

 

參考資料:https://blog.csdn.net/ypbsyy/article/details/80529101

https://blog.csdn.net/u010324465/article/details/77184506


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM