想在alpine基础镜像上加一个sshd用于管理,以做为制作其他镜像的基础境像
Dockerfile如下:
From alpine RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'
/etc/apk/repositories RUN apk update \ && apk add curl openrc openssh-server
RUN sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config \
&& rc-update add sshd RUN mkdir -p /run/openrc RUN touch /run/openrc/softlevel
RUN /etc/init.d/sshd restart
一、坑 cgroup
老是提示
/lib/rc/sh/openrc-run.sh: line 279: can’t create /sys/fs/cgroup/blkio/tasks:
Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create /sys/fs/cgroup/cpu/tasks:
Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/cpu,cpuacct/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/cpuacct/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create /sys/fs/cgroup/cpuset/tasks:
Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/devices/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/freezer/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/hugetlb/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create /sys/fs/cgroup/memory/tasks:
Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/net_cls/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/net_cls,net_prio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/net_prio/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/perf_event/tasks: Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create /sys/fs/cgroup/pids/tasks:
Read-only file system
/lib/rc/sh/openrc-run.sh: line 279: can’t create
/sys/fs/cgroup/systemd/tasks: Read-only file system

网上搜了很多资料,资料很少,唯一一个国外官网issue上的是只有提问,还没人回答。最终dockerfile加了一条:VOLUME [
“/sys/fs/cgroup” ] 解决了

二、坑 sshd自启动
Dockerfile 里加上这条:RUN /etc/init.d/sshd restart ,生成镜像不成功,提示:* WARNING: sshd is
already starting
不加上这条:生成镜像是成功了, 但sshd服务没启动,进到容器中,看sshd是stop状态, 再用“ /etc/init.d/sshd restart
”命令手工启动, 在另一台机器上sshd登陆测试,OK,没问题。但手工启动sshd的时候也没出现提示:* WARNING: sshd is already
starting 啊,为什么加到镜像中就不行呢?

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信