• docker-compose.yml

    version: '3.8'
    services:
    centos:
      image: centos:latest
      restart: always
      #network_mode: host
      container_name: centos_1022
      volumes: 
        #- /etc/localtime:/etc/localtime
        - ./data:/data
      ports:
        - "22:22"
      tty: true
      #command:
      #  - /bin/bash
      #privileged:true
      #environment:
    
  • sshd

yum -y install openssh-server

1.安装常用工具
    yum install -y vim lrzsz wget gcc-c++ pcre pcre-devel zlib zlib-devel ruby openssl openssl-devel patch bash-completion zlib.i686 libstdc++.i686 lsof unzip zip

2.service安装
    yum install initscripts  

3.ifconfig安装
    yum install net-tools.x86_64

4.ssh安装(10.0.75.1为docker的ip)
    sshd rpm -qa | grep ssh
    yum install openssh-server 
    service sshd restart
    #查看是否启动22端口 
    netstat -antp | grep sshd

1.修改sshd_config 为密码登录
    vim /etc/ssh/sshd_config
    #打开注释 PermitRootLogin yes, 允许密码登录,保存退出

2.设置root用户密码
    passwd root