今天使用portainer创建容器时容器启动不起来,于是使用命令行进行容器创建:
1 2 3 4
| docker pull ubuntu:22.04
docker run -d --name ycy-node2 -p 8001:22 ubuntu:22.04 sleep infinity
|
如果连不上docker网站,在/etc/docker/daemon.json中写入如下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| { "runtimes": { "nvidia": { "path": "/usr/bin/nvidia-container-runtime", "runtimeArgs": [] } }, "registry-mirrors": [ "http://hub.hpcxjtu.cn", "http://nvcr.hpcxjtu.cn", "https://docker.m.daocloud.io", "https://docker.imgdb.de", "https://docker-0.unsee.tech", "https://docker.hlmirror.com", "https://docker.1ms.run", "https://func.ink", "https://lispy.org", "https://docker.xiaogenban1993.com", "https://docker.mirrors.ustc.edu.cn" ] }
|
进入容器:
1
| docker exec -it ycy-node2 /bin/bash
|
在容器内设置SSH服务:
1 2 3 4 5
| #安装并启动ssh apt update && apt install -y openssh-server service ssh start #设置root密码 passwd
|
设置允许root登录:
1 2
| apt install vim vim /etc/ssh/sshd_config
|
添加或修改以下行:
重启SSH服务: