前言:
如今小伙伴们对“centos7修改shell”可能比较着重,姐妹们都需要知道一些“centos7修改shell”的相关资讯。那么小编同时在网摘上收集了一些有关“centos7修改shell””的相关资讯,希望姐妹们能喜欢,姐妹们快快来了解一下吧!制作自定义CentOS7 最小化的Docker镜像
一、从头创建一个CentOS的基础框架
首先安装好CentOS7,并在上面安装Docker,然后执行:
如果找不到该命令,用 yum install supermin* 安装
supermin5 --prepare yum -o supermin.d
supermin5 --build --format chroot supermin.d -o appliance.d
cd appliance.d
mv usr/share/locale/en usr/share/locale/en_US tmp
rm -rf usr/share/locale/*
mv tmp/en tmp/en_US usr/share/locale/
mv usr/share/i18n/locales/en_US tmp
rm -rf usr/share/i18n/locales/*
mv tmp/en_US usr/share/i18n/locales/
echo 7 > etc/yum/vars/releasever
cd ..
tar --numeric-owner -cpf centos7-zero.tar -C appliance.d .
cat centos7-zero.tar | docker import - local/centos7-zero
二、安装必要的组件,完成一个最小的CentOS7镜像
在主机上执行:
docker run -i -t local/centos7-zero /bin/bash
在container中执行:
# yum update -y
# yum install -y openssh* net-tools.x86_64 audit-libs basesystem bash binutils bzip2-libs ca-certificates centos-release chkconfig coreutils cpio cracklib cracklib-dicts curl cyrus-sasl-lib dbus-libs device-mapper device-mapper-libs diffutils elfutils-libelf expat fakesystemd file file-libs filesystem findutils gawk gdbm glib2 glibc glibc-common gmp gnupg2 gpgme grep groff-base gzip hardlink info iproute iptables iptables-services iputils keyutils-libs kmod-libs kpartx krb5-libs less libacl libassuan libattr libblkid libcap libcap-ng libcom_err libcroco libcurl libdb libdb-utils libffi libgcc libgcrypt libgomp libgpg-error libidn libmnl libmount libnetfilter_conntrack libnfnetlink libpwquality libselinux libsemanage libsepol libssh2 libstdc++ libtasn1 libunistring libuser libutempter libuuid libverto libxml2 lua ncurses ncurses-base ncurses-libs nspr nss nss-softokn nss-softokn-freebl nss-sysinit nss-tools nss-util openldap openssl-libs p11-kit p11-kit-trust pam pcre pinentry pkgconfig popt procps-ng pth pygpgme pyliblzma python python-iniparse python-libs python-pycurl python-urlgrabber pyxattr readline rootfiles rpm rpm-build-libs rpm-libs rpm-python sed setup shadow-utils shared-mime-info sqlite systemd-libs tzdata ustr util-linux vim-minimal which xz xz-libs yum yum-metadata-parser yum-plugin-fastestmirror zlib
# yum update -y && yum clean all
# exit
#bash: ifconfig: command not found
#yum search ifconfig
#yum -y install hostname.x86_64
#yum install passwd.x86_64
#vi /root/run.sh
#!/bin/sh
/usr/sbin/sshd -D &
/bin/bash
#修改shell提示符
export PS1='[\u@\H \w]\$ '
#保存新镜像
#docker commit 535d36af187e centos7:v1.1
在主机上执行:
# docker export > centos7-minimal.tar
docker ps -a
docker export 9a8ba4bc47d4 > centos7-minimal.tar
导入镜像
cat centos7-minimal.tar |docker import - centos7:v1.0
#启动镜像
docker run -itd -p 20022:22 centos7:v1.1 /run.sh
#查看docker ip
docker exec 5a6291208980 ip addr
#登录ssh
ssh root@172.17.0.2
密码: ld@2020
##############
制作镜像时想包含某个命令,但又不知道在哪个包时,可以用yum whatprovides 来查找
supermin5
Supermin 是一个用来创建迷你虚拟环境的工具,有点类似创建的迷你虚拟机环境
使用supermin5创建虚拟环境
注:以下命令需要使用root用户来执行
# mkdir myenv
# cd myenv
# 下面命令是准备要安装的软件包并保存在supermin.d目录下
# supermin5 -v --prepare bash coreutils iputils tar wget git vim yum python python2-pip -o supermin.d
# 下面命令是根据上一步准备的安装包目录制作隔离的环境,并保存在appliance.d目录下
# supermin5 -v --build --format chroot supermin.d -o appliance.d
# 如果要上网执行下面命令
# cp /etc/resolv.conf appliance.d/etc/
# 如果要使用yum安装软件包
# echo 7 > appliance.d/etc/yum/vars/releasever
标签: #centos7修改shell