系统环境:CentOS 7.3

将yum源切换到阿里源

可以直接写成一个脚本

#!/bin/sh
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

1. 安装Docker

[root@localhost ~]# yum -y install docker-engine
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker

2. 安装制作CentOS镜像的工具

[root@localhost ~]# yum -y install febootstrap

ps: CentOS7中的yum源没有febootstrap包,可以在CentOS6中使用 "yumdownloader febootstrap"命令将febootstrap下载到本地,之后放在7上进行安装

3. 制作CentOS镜像文件centos6-image目录

[root@localhost ~]# febootstrap -i bash -i wget -i yum -i iputils -i iproute -i man -i vim-minimal -i openssh-server -i openssh-clients centos6 centos6-image http://mirrors.aliyun.com/centos/6/os/x86_64/

PS:-i 安装package, centos6 操作系统版本,centos6-doc安装目录,最后是源地址

4. 制作Docker镜像,镜像名字是centos6-base

[root@localhost ~]# cd centos6-image && tar -c .|docker import - centos6-base

制作可以ssh登陆的Docker镜像,名字是centos6-ssh

1.创建一个Dockerfile文件

#Dockerfile
FROM centos6-base
RUN ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key
RUN sed -ri 's/session required pam_loginuid.so/#session required pam_loginuid.so/g' /etc/pam.d/sshd
RUN mkdir -p /root/.ssh && chown root.root /root && chmod /root/.ssh
EXPOSE
RUN echo 'root:123.com' | chpasswd
ENV LANG en_US.UTF-
ENV LC_ALL en_US.UTF-
CMD /usr/sbin/sshd -D
#End

Dockerfile

[root@localhost ~]# docker build -t centos6-ssh .

2.  创建容器

[root@localhost ~]# docker run -itd -p : centos6-ssh

3. ssh登陆容器

[root@localhost ~]# ssh root@127.0.0.1 -p 

Docker自制CentOS镜像的更多相关文章

  1. 关于Docker官方CentOS镜像无法启动mysqld的总结

    很多童鞋反映,在Docker官方CentOS镜像中安装了Mysql server后,无法正常启动. 无法正常启动表现为两种情况: 1> 初始完数据库后,mysqld启动报错 2> syst ...

  2. docker 启动 centos 镜像,容器会自动退出

    docker启动centos镜像有两种版本可以解决自动退出的问题: 方式一: docker run -d -it [image-ID] /bin/sh 方式二: 在启动脚本里面增加一个执行进程: 1. ...

  3. Docker的centos镜像内无法使用systemctl命令的解决办法

    在Docker官方的centos镜像内无法使用systemctl命令的解决办法, 使用该命令docker报错 Failed to get D-Bus connection: Operation not ...

  4. docker 自制CentOS 6-lnp镜像

    环境准备 1台centos 6.5镜像虚拟机  febootstrap.docker febootstrap 安装 yum install -y yum-priorities && r ...

  5. Docker 启动 Centos 镜像 提示"Error response from daemon: No command specified"

    奇怪的是当我执行启动其他的镜像的时候并没有报错,找了半天资料发现在启动centos这个镜像的时候需要在docker命令后面指定命令参数“/bin/bash”

  6. docker 自制alpine-lnp镜像

    简单粗暴点吧 jenkins 镜像下载:docker pull jenkins:alpine dockfile 原地址:https://gist.github.com/phith0n/373cc078 ...

  7. 2.docker下centos镜像

    1.下载并运行 # 交互模式下载并运行centos容器 $ docker run -it centos:latest /bin/bash 1.1 配置centos的环境别名 $ vi /etc/bas ...

  8. Docker安装CentOS

    系统环境: 腾讯云公共镜像 CoreOS 7.1 X64 #docker 下载centos镜像docker  pull   centos   #下载centos所有的镜像docker  pull   ...

  9. CentOS7安装Docker,运行Nginx镜像、Centos镜像

    摘要 总体思路:yum命令直接安装Docker,下载想要的镜像并启动 1.环境,CentOS7 Minimal 64位,Docker必须要64位的系统 2.通过yum命令直接安装,yum instal ...

随机推荐

  1. mskitten

    简介 一个普普通通的Java程序员,在某制造业外企工作. 技术栈 主要是Core Java,准备向Java Web挺进. 非计算机专业学生,在努力提升计算机基本素养(操作系统.算法).有好书好资源欢迎 ...

  2. vue报错信息

    1.Property or method "xxx" is not defined on the instance but referenced during render. 原因 ...

  3. Centos7安装Tomcat8

    一.下载Tomcat8压缩包 打开tomcat8的下载页面 http://tomcat.apache.org/download-80.cgi 二.解压以及重命名 [root@localhost ~]# ...

  4. Golang-教程

    http://www.runoob.com/go/go-environment.html https://www.pythonav.cn/

  5. Python-类的特性(property)

    什么是特性property property是一种特殊的属性,访问它时会执行一段功能(函数)然后返回值 例一:BMI指数(bmi是计算而来的,但很明显它听起来像是一个属性而非方法,如果我们将其做成一个 ...

  6. Python—生成器

    列表生成式 现在有个需求,看列表[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],要求你把列表里的每个值加1,你怎么实现? >>> a = [i+1 for i in r ...

  7. 全局关键字搜索:Element UI Table内容过滤\jQuery过滤器fastLiveFilter插件\BootstrapVue插件;

    ```html data:{ resultMaster: [], otableData:[], schfilter:'' } watch: { schfilter: function(val, old ...

  8. DWZ富客户端框架(jQuery RIA framework)

    该OA项目前端采用的是DWZ框架来进行实现的. 本来想写点总结的,但发现真没啥好写的.中文的文档,到时候用到直接看文档就好.

  9. openstack-KVM安装与使用

    一.KVM安装 1.安装条件 VT-x BIOS Intel9R) Virtualization Tech [Enabled] cat /proc/cpuinfo | grep -e vmx -e n ...

  10. [2017BUAA软工助教]常见问题Q&A

    软工常见问题Q&A 目录: 1. 转会相关 1.1 转会流程是什么样子的? 1.2 团队中多人要求转会怎么办?(如何解散团队) 1.3 为什么有人想要转会? 1.4 软件工程课为什么有这一环节 ...