Docker----openeuler-ssh容器镜像使用方法
作者:redrose2100   类别:    日期:2022-12-13 09:23:13    阅读:740 次   消耗积分:0 分

一、redrose2100/openeuler-ssh 镜像简介

redrose2100/openeuler-ssh的镜像仓库见 redrose2100/openeuler-ssh ,它为在openEuler镜像额基础上安装好sshd服务的镜像,并且设置了用户名root的密码为osImagePassword123,通过拉取此镜像即可直接启动可以ssh的容器。镜像的tag值与openEuler的镜像的tag值保持一致

二、redrose2100/openeuler-ssh 镜像应用

(1)创建一个网络,如下创建一个名为staticnet的网络,网段为172.18.0.0/16

  1. docker network create --subnet=172.18.0.0/16 staticnet

(2)查看网络如下

  1. [root@centos7-1 ~]# docker network ls
  2. NETWORK ID NAME DRIVER SCOPE
  3. 0eb4f2b7af54 bridge bridge local
  4. be204ec4735f host host local
  5. 1df66d2f7b49 none null local
  6. d6f5c693f28d staticnet bridge local
  7. [root@centos7-1 ~]#

(3)启动容器,指定网络同时设置容器的ip地址

  1. docker run -d --name=vm1 --privileged --net staticnet --ip 172.18.0.100 redrose2100/openeuler-ssh:22.03-lts /usr/sbin/sshd -D

(4)查看容器,如下,创建成功

  1. [root@centos7-1 ~]# docker ps
  2. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  3. 60fbd371e02c redrose2100/openeuler-ssh:22.03-lts "/usr/sbin/sshd -D" 5 seconds ago Up 4 seconds vm1
  4. [root@centos7-1 ~]#

(5)如下,通过ssh命令即可登录到容器,而且容器的ip地址配置也已经生效了

  1. [root@centos7-1 ~]# ssh -o "StrictHostKeyChecking=no" root@172.18.0.100
  2. root@172.18.0.100's password:
  3. Last failed login: Tue Dec 13 09:21:32 UTC 2022 from 172.18.0.1 on ssh:notty
  4. There was 1 failed login attempt since the last successful login.
  5. Welcome to 3.10.0-1160.el7.x86_64
  6. System information as of time: Tue Dec 13 09:21:56 AM UTC 2022
  7. System load: 0.03
  8. Processes: 8
  9. Memory used: 19.6%
  10. Swap used: .2%
  11. Usage On: 31%
  12. Users online: 0
  13. [root@60fbd371e02c ~]# ifconfig
  14. eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
  15. inet 172.18.0.100 netmask 255.255.0.0 broadcast 172.18.255.255
  16. ether 02:42:ac:12:00:64 txqueuelen 0 (Ethernet)
  17. RX packets 62 bytes 9502 (9.2 KiB)
  18. RX errors 0 dropped 0 overruns 0 frame 0
  19. TX packets 41 bytes 8108 (7.9 KiB)
  20. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  21. lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
  22. inet 127.0.0.1 netmask 255.0.0.0
  23. loop txqueuelen 1000 (Local Loopback)
  24. RX packets 0 bytes 0 (0.0 B)
  25. RX errors 0 dropped 0 overruns 0 frame 0
  26. TX packets 0 bytes 0 (0.0 B)
  27. TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
  28. [root@60fbd371e02c ~]#
始终坚持开源开放共享精神,同时感谢您的充电鼓励和支持!
版权所有,转载本站文章请注明出处:redrose2100, http://blog.redrose2100.com/article/501
个人成就
  • 2022年 : 371 篇 
  • 2023年 : 211 篇 
  • 2024年 : 31 篇 
  • 2025年 : 0 篇 
  • 博客总数: 613 
  • 阅读总量: 541745 
测试开发技术全栈公众号
DevOps技术交流微信群