Php 理解chroot

Php 理解chroot,php,linux,docker,uwsgi,chroot,Php,Linux,Docker,Uwsgi,Chroot,我在docker容器中运行用户应用程序,在我决定使用supervisorctl之前一切正常,这样我就可以通过rpc远程启动/停止应用程序。现在我需要一种方法来防止用户的应用程序内省容器、发现supervisord.conf&日志和/或执行supervisord/supervisorctl容器 实现这一点的方法是使用chroot,但我不清楚如何做到这一点 阅读uwsgi的文档只需运行 mkdir -p /ns/001 debootstrap maverick /ns/001 chroot /ns/

我在docker容器中运行用户应用程序,在我决定使用supervisorctl之前一切正常,这样我就可以通过rpc远程启动/停止应用程序。现在我需要一种方法来防止用户的应用程序内省容器、发现supervisord.conf&日志和/或执行supervisord/supervisorctl容器

实现这一点的方法是使用chroot,但我不清楚如何做到这一点

阅读uwsgi的文档只需运行

mkdir -p /ns/001
debootstrap maverick /ns/001
chroot /ns/001
# in the chroot jail now
adduser uwsgi
apt-get install mercurial python-flask
su - uwsgi
# as uwsgi now
git clone https://github.com/unbit/uwsgicc.git .
exit # out of su - uwsgi
exit # out of the jail
Now on your real system run

uwsgi --socket 127.0.0.1:3031 --chdir /home/uwsgi/uwsgi --uid uwsgi --gid uwsgi --module uwsgicc --master --processes 4 --namespace /ns/001:mybeautifulhostname
让uwsgi在chroot容器中运行

PHP-FPM似乎还有一个类似的配置选项,您必须在其中设置

prefix = /var/www/example.com
chroot = $prefix
chdir = /
listen = tmp/php5-fpm.sock
slowlog = log/$pool.log.slow
我不确定是否需要在容器中运行debootstrap。我也不明白在uwsgi的例子中是如何做到的;他们在chroot外部运行uwsgi bin,您不需要在chroot内部安装uwsgi,然后在chroot外部的supervisord.conf中安装类似于/ns/001/usr/bin/uwsgi的东西吗

我似乎找不到一个单一的标准方法来运行chroot和atm,所以我正在考虑运行类似的设置

RUN set -e;
    apk add --no-cache supervisor;
    mkdir -p /ns/001;
    debootstrap alpine /ns/001;
    chroot /ns/001;
    # in the chroot jail now
    # install all my packages here, all the stuff that was in the container apk add --no-cache everything
    before gets moved here
    # exit the chroot
    in my superisord.conf then just specify /ns/001/path/to/bins/in/chroot
上述方法是否可行

我想我也看到过一些例子,它们只对php fpm和uwsgi使用
chdir
选项,这是避免设置chroot环境的一种方法吗?非常简单的防止进程(比如python)超越chroot目录

chroot是否也会限制该过程所看到的env变量