【Docker】docker的一些常用命令

文章目录

通过镜像构建容器

console 复制代码
docker run -dti --gpus all --entrypoint /bin/bash --runtime=nvidia --name base_hexiang  --cgroupns host --ipc host -p 3917:32726/tcp --shm-size 1GB --ulimit memlock=-1 -v /mnt:/mnt --ipc=host 30778733900b

进入容器配置相关内容

console 复制代码
sudo docker exec -it base_hexiang /bin/bash

启动ssh服务

console 复制代码
netstat -tuln #查看状态
service ssh restart

编辑ssh文件

console 复制代码
vim /etc/ssh/sshd_config  # 修改 PasswordAuthentication 为 yes

service ssh restart

passwd # 为容器中的用户设置密码

配置ssh自动启动

con 复制代码
echo "service ssh start" >> /root/.bashrc  # 在容器中

通过ssh访问容器

console 复制代码
ssh root@ip -p 3917  #之后输入密码

将正在运行容器保存为新的镜像

console 复制代码
docker commit base_hexiang base_hexiang

docker stop hexiang  # 如果其是父亲镜像,则提示无法删除
docker rm hexiang

将Docker镜像上传到Harbor

console 复制代码
docker tag 
docker push
相关推荐
wj3055853783 小时前
课程 9:模型测试记录与 Prompt 策略
linux·人工智能·python·comfyui
abigriver4 小时前
打造 Linux 离线大模型级语音输入法:Whisper.cpp + 3090 显卡加速与 Rime 中英混输终极调优指南
linux·运维·whisper
wangqiaowq4 小时前
windows下nginx的安装
linux·服务器·前端
YYRAN_ZZU5 小时前
Petalinux新建自动脚本启动
linux
charlie1145141915 小时前
嵌入式Linux驱动开发pinctrl篇(1)——从寄存器到子系统:驱动演进之路
linux·运维·驱动开发
Agent手记5 小时前
异常考勤智能预警与处理与流程优化方案 | 基于企业级Agent的超自动化实战教程
运维·人工智能·ai·自动化
于小猿Sup5 小时前
VMware在Ubuntu22.04驱动Livox Mid360s
linux·c++·嵌入式硬件·自动驾驶
cen__y6 小时前
Linux12(Git01)
linux·运维·服务器·c语言·开发语言·git
不仙5207 小时前
VMware Workstation 26.0.0 在 Ubuntu 24.04 (内核 6.17.0) 上的安装与内核模块编译问题
linux·ubuntu·elasticsearch
AI视觉网奇8 小时前
linux 检索库 判断库是否支持
java·linux·服务器