How to use LD_PRELOAD in container runc

1k Views Asked by At

I followed this link and tried to use runc to launch a busybox container. I wanted to load a shared library into the container process with the LD_PRELOAD trick. I modified the args in config.json

        "args": [
                "sh"
        ],

to

        "args": [
                "LD_PRELOAD=preload.so sh"
        ],

It does not work as I expected. Is there a way to load a shared library with runc?

1

There are 1 best solutions below

0
On BEST ANSWER

Found a way to preload a shared library with runc:

        "args": [                                                       
                "sh"                                                  
        ],                                                              
        "env": [                                                        
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "TERM=xterm",                                           
                "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/init.so"    
        ],