Dcokerfile构建Centos-ssh镜像
来源:互联网 发布:刘邦历史书籍 知乎 编辑:程序博客网 时间:2024/05/29 18:15
创建Dockerfile 文件
[root@localhost ~]# cd /data[root@localhost data]# mkdir ssh01
[root@localhost data]# cd ssh01/
[root@localhost ssh01]# yum install vim -y
[root@localhost ssh01]# pwd
/data/ssh01
[root@localhost ssh01]# vim Dockerfile
[root@localhost ssh01]# cat Dockerfile
# 设置基本的镜像,后续命令都以这个镜像为基础FROM docker.io/centos:latest # 作者信息MAINTAINER shangwu# RUN命令会在上面指定的镜像里执行任何命令RUN yum install passwd openssl openssh-server -yRUN echo '888888' | passwd --stdin rootRUN ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ''RUN ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''RUN sed -i '/^session\s\+required\s\+pam_loginuid.so/s/^/#/' /etc/pam.d/sshdRUN mkdir -p /root/.ssh && chown root.root /root && chmod 700 /root/.sshRUN yum install wget net-tools -yRUN mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backupRUN wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repoRUN wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repoRUN yum clean allENV LANG en_US.UTF-8ENV LC_ALL en_US.UTF-8RUN mkdir /var/run/sshd#暴露ssh端口22EXPOSE 22#设定运行以daemon方式启动sshdCMD ["/usr/sbin/sshd", "-D"]
[root@localhost ssh01]#
开始构建
[root@localhost ssh01]# docker build -t sw-centos-ssh:v1.0.1 .[root@localhost ssh01]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sw-centos-ssh v1.0.1 8abdecd1d6b5 8 seconds ago 315.2 MB
启动容器
[root@localhost ssh01]# docker run -d -p 8031:22 --name=swtest1 sw-centos-ssh:v1.0.1 /usr/sbin/init0a075194063e723bf2bfa023a8f2d73f5199e854182cbc2a76e4a9a763093213
测试是否构建成功
[root@localhost ssh01]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0a075194063e sw-centos-ssh:v1.0.1 "/usr/sbin/sshd -D" 18 seconds ago Up 15 seconds 0.0.0.0:8031->22/tcp swtest1
[root@localhost ssh01]#
[root@localhost ssh01]# docker inspect 0a075194063e | grep "IPA"
"SecondaryIPAddresses": null,
"IPAddress": "172.17.0.4",
"IPAMConfig": null,
"IPAddress": "172.17.0.4",
Centos安装httpd
安装httpd[root@0a075194063e ~]# yum install httpd -y修改配置vim /etc/httpd/conf/httpd.conf......ServerName localhost:80......启动[root@3f6a3283f006 ~]# systemctl start httpd [root@3f6a3283f006 ~]# systemctl enable httpd 查看httpd进程[root@0a075194063e html]# ps aux |grep httpdroot 189 0.0 0.0 12464 968 pts/0 S+ 09:54 0:00 grep --color=auto httpd启动[root@0a075194063e html]# httpd[root@0a075194063e html]# ps aux |grep httpdroot 191 0.0 0.1 221936 3360 ? Ss 09:54 0:00 httpdapache 192 0.0 0.1 221936 2940 ? S 09:54 0:00 httpdapache 193 0.0 0.1 221936 2940 ? S 09:54 0:00 httpdapache 194 0.0 0.1 221936 2940 ? S 09:54 0:00 httpdapache 195 0.0 0.1 221936 2940 ? S 09:54 0:00 httpdapache 196 0.0 0.1 221936 2940 ? S 09:54 0:00 httpdroot 198 0.0 0.0 12464 964 pts/0 S+ 09:54 0:00 grep --color=auto httpd[root@0a075194063e html]# 停止httpd[root@0a075194063e html]# httpd -k stop
阅读全文
0 0
- Dcokerfile构建Centos-ssh镜像
- Docker构建ssh镜像
- 构建支持SSH服务的镜像
- 利用Dockerfile构建一个基于CentOS 7镜像参考
- 构建自己的centos+jdk7+tomcat8的docker镜像
- 创建支持SSH服务的CentOS镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 通过Dockerfile创建支持SSH服务的CentOS镜像
- 启动多个centos-ssh-http镜像容器
- 通过Dockerfile创建SSH服务的CentOS镜像
- CentOS下Docker安装和centos+jdk镜像构建与jar包在镜像中启动
- Docker构建镜像
- 构建镜像
- Dockerfile 构建镜像
- docker_Dockerfile构建镜像
- 构建Tomcat镜像
- docker8 构建镜像
- csdn有用以及打算学习实践的技术和资源
- maven pom.xml设置jdk编译版本为1.8
- 整机调试连不上手机时解决办法
- 时间:UTC时间、GMT时间、本地时间、Unix时间戳
- 金钱格式化
- Dcokerfile构建Centos-ssh镜像
- GITLAB修改分支权限
- Android kotlin入门与基础语法二
- 编译时注解解析
- Node -- 模块机制
- try,catch
- CentOS-解决CentOS 7 history命令不显示操作记录的时间和用户身份问题
- profiles 配置
- java现在还很热!