A execução de um comando do host para o contêiner o processará pelo daemon do docker.
Se você exec -it [image ID] bash
e, em seguida, testar a hora:
$ docker exec -it php bash
root@0fddab587d30:/# time php -i > /dev/null
real 0m0.029s
user 0m0.011s
sys 0m0.018s
Executando strace
no host, através do dockerd para o contêiner
$ strace -c -f -S name docker run -d --rm php:cli php -i > /dev/null
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.04 0.000073 7 10 10 access
0.01 0.000025 25 1 arch_prctl
0.04 0.000064 21 3 brk
0.21 0.000359 45 8 clone
0.09 0.000158 9 17 close
0.02 0.000036 9 4 2 connect
0.02 0.000027 27 1 epoll_create1
0.04 0.000068 11 6 epoll_ctl
3.97 0.006676 56 120 epoll_wait
0.00 0.000000 0 1 execve
0.03 0.000056 14 4 fcntl
0.05 0.000082 6 13 fstat
72.92 0.122754 128 959 161 futex
0.00 0.000001 1 2 getpeername
0.00 0.000000 0 1 getpid
0.01 0.000022 22 1 getrandom
0.00 0.000000 0 2 getsockname
0.12 0.000199 22 9 gettid
0.00 0.000004 4 1 getuid
0.03 0.000044 22 2 1 ioctl
0.01 0.000011 6 2 lseek
0.78 0.001317 20 67 mmap
0.49 0.000821 24 34 mprotect
0.25 0.000427 39 11 munmap
0.01 0.000013 13 1 open
0.09 0.000154 11 14 openat
0.02 0.000027 27 1 prlimit64
17.57 0.029574 78 381 pselect6
0.10 0.000166 7 23 6 read
0.03 0.000046 46 1 readlinkat
1.50 0.002522 20 128 rt_sigaction
0.74 0.001241 9 132 rt_sigprocmask
0.02 0.000032 32 1 sched_getaffinity
0.30 0.000500 18 28 sched_yield
0.10 0.000175 19 9 set_robust_list
0.01 0.000025 25 1 set_tid_address
0.00 0.000000 0 2 setsockopt
0.19 0.000323 18 18 sigaltstack
0.03 0.000044 11 4 socket
0.13 0.000215 8 28 27 stat
0.03 0.000049 10 5 write
------ ----------- ----------- --------- --------- ----------------
100.00 0.168330 2056 207 total
E com o stracing em execução no contêiner php:cli
, o tempo é significativamente menor, mesmo com mais syscalls, parece que o futex
syscall é uma preocupação aqui:
$ docker run -it --security-opt seccomp:unconfined php:cli bash
root@3bd1a83a2586:/# apt update && apt install strace
root@3bd1a83a2586:/# strace -c -f -S name php -i > /dev/null
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
4.38 0.000830 15 55 54 access
0.03 0.000006 6 1 arch_prctl
0.00 0.000000 0 15 brk
2.73 0.000518 8 61 close
0.00 0.000000 0 1 execve
3.74 0.000708 12 61 fstat
0.02 0.000003 0 18 futex
0.00 0.000000 0 1 getcwd
0.00 0.000000 0 2 getdents
0.00 0.000000 0 3 getrandom
0.00 0.000000 0 2 getrlimit
0.00 0.000000 0 1 1 ioctl
0.00 0.000000 0 2 lseek
0.00 0.000000 0 5 1 lstat
0.00 0.000000 0 1 madvise
10.42 0.001974 14 145 mmap
5.06 0.000959 9 108 mprotect
0.24 0.000046 4 13 munmap
10.34 0.001960 28 69 9 open
3.45 0.000654 10 63 read
0.00 0.000000 0 80 rt_sigaction
0.00 0.000000 0 2 rt_sigprocmask
0.00 0.000000 0 1 set_robust_list
0.00 0.000000 0 1 set_tid_address
0.00 0.000000 0 1 socket
0.23 0.000043 7 6 4 stat
0.00 0.000000 0 1 sysinfo
0.00 0.000000 0 1 uname
59.36 0.011250 4 3037 write
------ ----------- ----------- --------- --------- ----------------
100.00 0.018951 3757 69 total