# steps-01:配置文件:Dockerfile-centos-7
FROM hub.c.163.com/netease_comb/centos:7
MAINTAINER netease
# 更新yum的安装源
RUN yum makecache fast && yum -y update glibc
# 安装常用软件
RUN yum install -y openssh-server vim tar wget curl rsync bzip2 iptables tcpdump less telnet net-tools lsof
# 初始化ssh登陆
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
RUN ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
RUN ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
RUN ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ''
RUN echo "RSAAuthentication yes" >> /etc/ssh/sshd_config
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config
RUN yum clean all
# 启动sshd服务并且暴露22端口
RUN mkdir /var/run/sshd
EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]
# steps-02:构建镜像
docker build -t hub.c.163.com/yemiancheng/centos:7 -f ./Dockerfile-centos-7 .
# steps-03:登录仓库
docker login hub.c.163.com
# steps-04:上传镜像
docker push hub.c.163.com/yemiancheng/centos:7
# 参考:
# 通过配置文件搭建镜像--https://www.163yun.com/help/documents/68510213955833856
# 搭建操作系统centos:https://c.163yun.com/hub#/m/repository/?repoId=1055
# steps-01:配置文件:Dockerfile-nodejs
FROM hub.c.163.com/netease_comb/centos:7
MAINTAINER netease
# 更新yum的安装源
RUN yum -y update
# 安装常用软件
RUN yum install -y gcc make gcc-c++ openssl-devel wget
# 初始化ssh登陆
RUN cd /usr/local/src && wget http://nodejs.org/dist/v0.12.5/node-v0.12.5.tar.gz
RUN tar -xzvf node-v0.12.5.tar.gz \
&& cd node-v0.12.5 && ./configure \
&& make && make install && rm -f node-v0.12.5.tar.gz \
RUN sudo ln -s /usr/local/bin/node /usr/bin/node \
&& sudo ln -s /usr/local/lib/node /usr/lib/node \
&& sudo ln -s /usr/local/bin/npm /usr/bin/npm
# 设置允许root ssh远程登录
RUN sed -i s/"PermitRootLogin without-password"/"PermitRootLogin yes"/g /etc/ssh/sshd_config
EXPOSE 22
# SSH终端服务器作为后台运行
ENTRYPOINT /usr/bin/node && /usr/sbin/sshd -D
# steps-02:构建镜像
docker build -t hub.c.163.com/yemiancheng/nodejs:v0.12.5 -f ./Dockerfile-nodejs .
# steps-03:登录仓库
docker login hub.c.163.com
# steps-04:上传镜像
docker push hub.c.163.com/yemiancheng/nodejs:v0.12.5
网友评论