Giter VIP home page Giter VIP logo

yamc's Introduction

YAMC

一个 rootless 的对程序进行时空测量的简单容器。

依赖

  • Linux 4.18 及以上。需要 cgroup v1。
  • glog

使用

  1. 为 yamc 准备一个容器内使用的账户
useradd -u 1720 -M -s /usr/sbin/nologin yamc
  1. 配置 subuidsubgid
echo "`id -u`:1720:1" >> /etc/subuid
echo "`id -u`:1720:1" >> /etc/subgid
  1. 为 yamc 创建 cgroup 跟目录
base_dir='/sys/fs/cgroup'
# root needed
for sys in memory cpu cpuacct pids;
do
      mkdir -p "$base_dir/$sys/yamc"
      chown 1720:1720 "$base_dir/$sys/yamc"
      chown 1720:1720 "$base_dir/$sys/yamc/cgroup.procs"
done
  1. 开跑
yamc -u 1720 -g 1720 -- echo 233

可能出现的问题

  1. debian 10

debian 10 以及更旧的版本默认只有 root 用户可以创建 user namespace, 该 patch 在 debian 11 中被移除。

参考 https://superuser.com/questions/1094597/enable-user-namespaces-in-debian-kernel 取消这一限制。

同样应该检查 user.max_user_namespaces 的值是否合理。

  1. 默认根目录

容器默认不挂载 /etc/alternatives/usr/libexec/,这可能导致一些语言运行时不可用。

感谢

以上项目提供参考。

挖坑

迁移到 cgroup v2。(需要内核版本支持)

yamc's People

Contributors

fitenne avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.