Centos7 From Yi
- docker pull centos
- Excution : Docker build -t ‘yi/centos7-ssh’ .
FROM centos
MAINTAINER Yi.Ma <findlymw@gmail.com>
RUN yum -y update
RUN yum install -y passwd openssh-server openssh-clients initscripts net-tool
RUN yum install python-setuptools -y
RUN easy_install supervisor
RUN echo 'root:root' | chpasswd
RUN /usr/sbin/sshd-keygen
EXPOSE 22
CMD /usr/sbin/sshd -D
supervisor 通过脚本进行多应用的启动
使用yum install python-setuptools -y来安装supervisor
默认的yum安装不了 supervisor
RUN yum install python-setuptools -y
RUN easy_install supervisor
出现错误及解决:
1.首先需要更换国内源(阿里源)
1、备份源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3、非阿里云ECS用户会出现 Couldn’t resolve host ‘mirrors.cloud.aliyuncs.com’ 信息,不影响使用,可以修改配置
sed -i -e ‘/mirrors.cloud.aliyuncs.com/d’ -e ‘/mirrors.aliyuncs.com/d’ /etc/yum.repos.d/CentOS-Base.repo
4、生成缓存
yum makecache
5、查看当前源
yum repolist
2.报错initscripts net-tool名错,及后续错误
将centos改为centos:7,之后的错误出现在RUN easy_install supervisor,即下图。
解决:单独执行
yum -y update
yum install -y passwd openssh-server openssh-clients initscripts net-tools
yum install python-setuptools -y
执行完这三步后:RUN easy_install supervisor
错误解决
easy_install不稳定,所以这一步使用pip(pip是easy_install的改进版,提供更好的提示信息,删除package等功能,老版本的python只有easy_install,没有pip)
-
使用 yum 安装pip
-
yum -y install epel-release
-
yum -y install python-pip
-
yum clean all
-
pip install docker-compose
python中升级pip报错_Python PIP升级后执行命令报错: sys.stderr.write(f"ERROR: {exc}")解决方法…
报错信息:Traceback (most recent call last):
File “/usr/bin/pip2”, line 9, in
load_entry_point(‘pip==21.0’, ‘console_scripts’, ‘pip2’)()
File “/usr/lib/python2.7/site-packages/pkg_resources.py”, line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/lib/python2.7/site-packages/pkg_resources.py”, line 2566, in load_entry_point
return ep.load()
File “/usr/lib/python2.7/site-packages/pkg_resources.py”, line 2260, in load
entry = import(self.module_name, globals(),globals(), [‘name’])
File “/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py”, line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax问题原因:
Python 2.7已于2020年1月1日到期,请停止使用。请升级您的Python,因为不再维护Python 2.7。pip 21.0将于2021年1月停止对Python 2.7的支持。pip 21.0将删除对此功能的支持。解决此问题并继续使用不受支持的Python 2.7,不应升级到最新的pip版本,而应升级到<21的版本。
解决方法:pip install --upgrade “pip < 21.0”
或者curl https://bootstrap.pypa.io/2.7/get-pip.py --output get-pip.py
此问题解决来源:https://blog.csdn.net/weixin_33462167/article/details/113968683
-
-
pip方式安装supervisor
pip install supervisor
到此已经完成了以下命令
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-onSbOkls-1622739928668)(C:\Users\ASUS\AppData\Roaming\Typora\typora-user-images\image-20210604004810208.png)]
最后的错误:
报错:/sbin/sh: /usr/sbin/sshd-keygen: No such file or directory
找到其地址 直接执行 /usr/sbin/sshd-keygen
将单步执行过的命令删掉,通过Dockerfile挂载镜像
-
docker build ‐t yi/centos7‐ssh .