centos7 ssh dockerfile

 

 

centos7 ssh  dockerfile

FROM centos:centos7.7.1908
ENV PATH $PATH:/usr/local/mysql/bin/

RUN yum -y install wget
RUN rm -rf /etc/yum.repos.d/*
RUN cd /etc/yum.repos.d/ \
&& wget http://mirrors.aliyun.com/repo/Centos-7.repo \
&& wget http://mirrors.aliyun.com/repo/epel-7.repo
RUN yum clean all
RUN yum install -y openssh-server bind-utils sysstat telnet net-tools glibc-common gcc automake autoconf libtool make gcc-c++ unzip libaio-devel numactl vim openssh*

RUN sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' /etc/ssh/sshd_config
RUN sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config

RUN echo '123456' | passwd --stdin root
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key


COPY mysql /usr/local/mysql
ADD my.cnf /etc/

RUN mkdir -p /data/mysql/mysql3306/{data,logs,temp} \
&& groupadd mysql \
&& useradd -g mysql -s /sbin/nologin -d /usr/local/mysql -MN mysql \
&& echo "PATH=$PATH:/usr/local/mysql/bin/" >>/etc/profile \
&& chown -R mysql.mysql /data/mysql

RUN chown -R mysql.mysql /usr/local/mysql

# ------------------------------------------------------------------------------
ADD localtime /etc/localtime

RUN mkdir /var/run/sshd

WORKDIR /root/

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

 

docker run -d  --name master  -h master centos7-ssh-test
docker run -d  --name slave1  -h slave1 centos7-ssh-test
docker run -d  --name slave2  -h slave2 centos7-ssh-test
docker run -d  --name slave3  -h slave3 centos7-ssh-test
docker run -d  --name proxysql  -h proxysql --privileged centos7-ssh-test /usr/sbin/init

 

posted @ 2020-03-15 10:59  fengjian1585  阅读(273)  评论(0编辑  收藏  举报