惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

西行妖

T618冷门平板刷机从入门到理赔 12700h es新all in Boom折腾记录 Kde6 Electron程序在wayland模式下无法运行终极解决方案 蜗牛星际NAS再次折腾记录 2023年度总结 CS61B最后的总结:比较排序与基数排序 工程机,我劝你别买 为thinkbook14p G3更换高刷屏幕 专有名词笔记 时间轴 谷歌域名即将被收购,如何薅到最后一波羊毛 人在囧途——记录我的日本之行 记一次衣服被子被偷的离谱经历 关于本站迁移的公告 java的某些常用特性 python3将对象作为线程使用 在Chromebook上使用Windows是什么体验?记录我到目前为止用过的Chromebook Chromebook刷bios解除企业锁折腾记录 Vue3的computed计算属性传参 将操作系统从Windows转向Linux [预告]固态硬盘太贵?试试看自己做一个吧 A卡深度学习服务器折腾&踩坑记 Ai绘画体验——利用校徽生成对应虚拟形象 AutoWhitelist诈尸更新dev&新的未来计划 它很好,但对我来说不够好——关于华硕无双15.6 [推广]蓝易云暑期大采购活动 Potplayer+SVP4插帧看番体验——24帧日漫轻松提升至60帧 AList搭建教程&网盘迁移至AList公告 Autowhitelist介绍&我对mc白名单的研究 还是v2ex大神多,记一次遇到bug被大佬拯救 关于MC服务器毁档重开 对于本站消失的回应 利用蹩脚的 js 知识写了一个统计真实访客数量的脚本 谈谈我高中时用过的手机 高考前夕,再谈我的想法 轻松搭建gitlab私人代码库 每周灵感 - 01 每周灵感 - 00 heroku使用教程——真正的零成本搭建PHP动态博客 关于tencent-push项目的总结&后续计划 我们已经失去了辩论能力吗?关于我对“拉黑”的看法 似乎更不好的近况 不怎么好的近况 记一次我与某网课系统的对抗 高考96天倒计时,我想说的话&以后的一些计划 关于最近俄乌局势我的看法 本站打算做出的一些改变&我对网左/键政的看法 [转发]我是衡水桃城中学的一名学生 关于西安节点合作商“昔年”跑路的公告 什么才是年轻人需要的文化?我对于“抵制洋节”的看法 平顶山刘玉坤事件接力 友情链接 关于本站数据丢失&抢救 关于我 关于我新搭建的oneindex网盘(附教程) [纯教程]如何搭建QQ微信转发服务器 关于我新买的LG V50&如何搭建QQ第三方推送服务器 三胎政策的出台,是否意味着政府已经急了?关于我对生育率的思考 网站更新&迟来的4月总结 如何看待“网抑云”这一现象的流行 如何用阿里云服务器开一个我的世界皮肤站
在Docker容器中运行服务
2023-03-24 · via 西行妖

最近正在写的某个容器升级了一下架构,在启动容器时需要同时运行一个frps服务。根据我的习惯,一开始打算使用systemctl添加frps服务,然后enable一下以实现开机自启。但在我实际使用时,发现服务没有跑起来。查了一下日志,发现了这条报错:

ERROR:systemctl: frps.service: Executable path is not absolute, ignoring: ./frps -c /frps.ini ERROR:systemctl: Exec is not an absolute path: ExecStart=./frps -c /frps.ini ERROR:systemctl: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ERROR:systemctl: Found 1 problems in /etc/systemd/system/frps.service ERROR:systemctl: The SystemD commands must always be absolute paths by definition. ERROR:systemctl: Earlier versions of systemctl.py did use a subshell thus using $PATH ERROR:systemctl: however newer versions use execve just like the real SystemD daemon ERROR:systemctl: so that your docker-only service scripts may start to fail suddenly. ERROR:systemctl: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

去官网稍微找了下,发现了这段解释:

This is by design. Docker should be running a process in the foreground in your container and it will be spawned as PID 1 within the container’s pid namespace. Docker is designed for process isolation, not for OS virtualization, so there are no other OS processes and daemons running inside the container (like systemd, cron, syslog, etc), only your entrypoint or command you run. If they included systemd commands, you’d find a lot of things not working since your entrypoint replaces init. Systemd also makes use to cgroups which docker restricts inside of containers since the ability to change cgroups could allow a process to escape the container’s isolation. Without systemd running as init inside your container, there’s no daemon to process your start and stop commands.

大意就是:docker只是提供了进程隔离,不是操作系统的虚拟,所以不能运行systemd。

如果只想同时运行两个服务,应该用什么办法呢?其实很简单:在Dockerfile CMD内运行start.sh,然后再用nohup挂起frps服务就好了: nohup ./frps -c /frps.ini & python3 /main.py 顺利运行frps服务。