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.
-
啟動ssh服務,service ssh start
-
退出容器,輸入exit,然后輸入docker ps -a,查看容器的ID
-
提交容器成為新的鏡像,例如叫做ubuntu-ssh,輸入docker commit 容器ID ubuntu-ssh
7.設置ssh密碼:$ passwd root
Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully