2016-12-30 156 views
1

我正在尋找一個rkt命令,它等同於以下docker命令:執行命令,然後退出

docker run nginx:1.11.5 find/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null 

docker命令從nginx:1.11.5新的容器,執行find/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null在容器內(打印所有具有setuid和setgid權限的二進制文件到標準輸出),然後殺死容器。結果是這個樣子:

[email protected]:~# docker run nginx:1.11.5 find/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null 
-rwsr-xr-x 1 root root 40168 Nov 18 2015 /bin/su 
-rwsr-xr-x 1 root root 40000 Mar 29 2015 /bin/mount 
-rwsr-xr-x 1 root root 27416 Mar 29 2015 /bin/umount 
-rwsr-xr-x 1 root root 61392 Oct 28 2014 /bin/ping6 
-rwsr-xr-x 1 root root 70576 Oct 28 2014 /bin/ping 
-rwsr-xr-x 1 root root 53616 Nov 18 2015 /usr/bin/chfn 
-rwsr-xr-x 1 root root 39912 Nov 18 2015 /usr/bin/newgrp 
-rwxr-sr-x 1 root tty 27232 Mar 29 2015 /usr/bin/wall 
-rwsr-xr-x 1 root root 54192 Nov 18 2015 /usr/bin/passwd 
-rwxr-sr-x 1 root shadow 22744 Nov 18 2015 /usr/bin/expiry 
-rwsr-xr-x 1 root root 75376 Nov 18 2015 /usr/bin/gpasswd 
-rwsr-xr-x 1 root root 44464 Nov 18 2015 /usr/bin/chsh 
-rwxr-sr-x 1 root shadow 62272 Nov 18 2015 /usr/bin/chage 
-rwxr-sr-x 1 root shadow 35408 Jan 28 2016 /sbin/unix_chkpwd 

這是我到目前爲止已經試過:

rkt run --insecure-options=image --net=host docker://nginx find/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null 

rkt run --insecure-options=image --net=host docker://nginx --exec find/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null 

兩者不返回輸出。

我能獲得通過重寫與--exec /bin/bash初始命令並添加--interactive標誌,像這樣我想要的信息:

[email protected]:~# rkt run --interactive --insecure-options=image --net=host docker://nginx --exec /bin/bash 
[email protected]:/# find/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null 
-rwxr-sr-x 1 root shadow 35408 Jan 28 2016 /sbin/unix_chkpwd 
-rwsr-xr-x 1 root root 40000 Mar 29 2015 /bin/mount 
-rwsr-xr-x 1 root root 61392 Oct 28 2014 /bin/ping6 
-rwsr-xr-x 1 root root 40168 Nov 18 2015 /bin/su 
-rwsr-xr-x 1 root root 27416 Mar 29 2015 /bin/umount 
-rwsr-xr-x 1 root root 70576 Oct 28 2014 /bin/ping 
-rwxr-sr-x 1 root tty 27232 Mar 29 2015 /usr/bin/wall 
-rwsr-xr-x 1 root root 75376 Nov 18 2015 /usr/bin/gpasswd 
-rwsr-xr-x 1 root root 44464 Nov 18 2015 /usr/bin/chsh 
-rwsr-xr-x 1 root root 53616 Nov 18 2015 /usr/bin/chfn 
-rwsr-xr-x 1 root root 54192 Nov 18 2015 /usr/bin/passwd 
-rwxr-sr-x 1 root shadow 62272 Nov 18 2015 /usr/bin/chage 
-rwxr-sr-x 1 root shadow 22744 Nov 18 2015 /usr/bin/expiry 
-rwsr-xr-x 1 root root 39912 Nov 18 2015 /usr/bin/newgrp 
[email protected]:/# exit 
exit 
[email protected]:~# 

我將如何做到這一點的一個命令?

回答

1

您需要使用--將參數傳遞給圖像。

[email protected]:~# rkt run --insecure-options=image --net=host docker://nginx --exec find --/-perm +6000 -type f -exec ls -ld {} \; 2> /dev/null 
[ 4356.161333] nginx[5]: -rwxr-sr-x 1 root shadow 62272 Feb 24 08:09 /usr/bin/chage 
[ 4356.163359] nginx[5]: -rwsr-xr-x 1 root root 53616 Feb 24 08:09 /usr/bin/chfn 
[ 4356.165202] nginx[5]: -rwsr-xr-x 1 root root 44464 Feb 24 08:09 /usr/bin/chsh 
[ 4356.167506] nginx[5]: -rwxr-sr-x 1 root shadow 22744 Feb 24 08:09 /usr/bin/expiry 
[ 4356.169553] nginx[5]: -rwsr-xr-x 1 root root 75376 Feb 24 08:09 /usr/bin/gpasswd 
[ 4356.171651] nginx[5]: -rwsr-xr-x 1 root root 39912 Feb 24 08:09 /usr/bin/newgrp 
[ 4356.173452] nginx[5]: -rwsr-xr-x 1 root root 54192 Feb 24 08:09 /usr/bin/passwd 
[ 4356.175704] nginx[5]: -rwxr-sr-x 1 root tty 27232 Mar 29 2015 /usr/bin/wall 
[ 4356.229841] nginx[5]: -rwsr-xr-x 1 root root 40000 Mar 29 2015 /bin/mount 
[ 4356.231914] nginx[5]: -rwsr-xr-x 1 root root 70576 Oct 28 2014 /bin/ping 
[ 4356.234003] nginx[5]: -rwsr-xr-x 1 root root 61392 Oct 28 2014 /bin/ping6 
[ 4356.235932] nginx[5]: -rwsr-xr-x 1 root root 40168 Feb 24 08:09 /bin/su 
[ 4356.237872] nginx[5]: -rwsr-xr-x 1 root root 27416 Mar 29 2015 /bin/umount 
[ 4356.250513] nginx[5]: /usr/bin/find: `/proc/5/task/5/fd/5': No such file or directory 
[ 4356.250812] nginx[5]: /usr/bin/find: `/proc/5/task/5/fdinfo/5': No such file or directory 
[ 4356.251120] nginx[5]: /usr/bin/find: `/proc/5/fd/5': No such file or directory 
[ 4356.251355] nginx[5]: /usr/bin/find: `/proc/5/fdinfo/5': No such file or directory 
[ 4356.254186] nginx[5]: -rwxr-sr-x 1 root shadow 35408 Nov 12 07:43 /sbin/unix_chkpwd 

查看https://coreos.com/rkt/docs/latest/subcommands/run.html#passing-arguments瞭解更多信息。

相關問題