偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Docker基礎(chǔ)技術(shù):Linux Namespace(上)

運(yùn)維 系統(tǒng)運(yùn)維
時下最熱的技術(shù)莫過于Docker了,Docker和Docker衍生的東西用到了很多很酷的技術(shù),我會用幾篇 文章來把這些技術(shù)給大家做個介紹,希望通過這些文章大家可以自己打造一個山寨版的docker。

[[171779]]

時下最熱的技術(shù)莫過于Docker了,很多人都覺得Docker是個新技術(shù),其實(shí)不然,Docker除了其編程語言用go比較新外,其實(shí)它還真不是個新東西,也就是個新瓶裝舊酒的東西,所謂的The New “Old Stuff”。Docker和Docker衍生的東西用到了很多很酷的技術(shù),我會用幾篇 文章來把這些技術(shù)給大家做個介紹,希望通過這些文章大家可以自己打造一個山寨版的docker。

當(dāng)然,文章的風(fēng)格一定會尊重時下的“流行”——我們再也沒有整塊整塊的時間去看書去專研,而我們只有看微博微信那樣的碎片時間(那怕我們有整塊的時間,也被那些在手機(jī)上的APP碎片化了)。所以,這些文章的風(fēng)格必然堅持“馬桶風(fēng)格”(希望簡單到占用你拉一泡屎就時間,而且你還不用動腦子,并能學(xué)到些東西)

廢話少說,我們開始。先從Linux Namespace開始。

簡介

Linux Namespace是Linux提供的一種內(nèi)核級別環(huán)境隔離的方法。不知道你是否還記得很早以前的Unix有一個叫chroot的系統(tǒng)調(diào)用(通過修改根目錄把用戶jail到一個特定目錄下),chroot提供了一種簡單的隔離模式:chroot內(nèi)部的文件系統(tǒng)無法訪問外部的內(nèi)容。Linux Namespace在此基礎(chǔ)上,提供了對UTS、IPC、mount、PID、network、User等的隔離機(jī)制。

舉個例子,我們都知道,Linux下的超級父親進(jìn)程的PID是1,所以,同chroot一樣,如果我們可以把用戶的進(jìn)程空間jail到某個進(jìn)程分支下,并像chroot那樣讓其下面的進(jìn)程 看到的那個超級父進(jìn)程的PID為1,于是就可以達(dá)到資源隔離的效果了(不同的PID namespace中的進(jìn)程無法看到彼此)

šLinux Namespace 有如下種類,官方文檔在這里《Namespace in Operation

主要是š三個系統(tǒng)調(diào)用

  • šclone() – 實(shí)現(xiàn)線程的系統(tǒng)調(diào)用,用來創(chuàng)建一個新的進(jìn)程,并可以通過設(shè)計上述參數(shù)達(dá)到隔離。
  • šunshare() – 使某進(jìn)程脫離某個namespace
  • šsetns() – 把某進(jìn)程加入到某個namespace

unshare() 和 setns() 都比較簡單,大家可以自己man,我這里不說了。

下面還是讓我們來看一些示例(以下的測試程序最好在Linux 內(nèi)核為3.8以上的版本中運(yùn)行,我用的是ubuntu 14.04)。

clone()系統(tǒng)調(diào)用

首先,我們來看一下一個最簡單的clone()系統(tǒng)調(diào)用的示例,(后面,我們的程序都會基于這個程序做修改):

  1. #define _GNU_SOURCE 
  2. #include <sys/types.h> 
  3. #include <sys/wait.h> 
  4. #include <stdio.h> 
  5. #include <sched.h> 
  6. #include <signal.h> 
  7. #include <unistd.h> 
  8.  
  9. /* 定義一個給 clone 用的棧,棧大小1M */ 
  10. #define STACK_SIZE (1024 * 1024) 
  11. static char container_stack[STACK_SIZE]; 
  12.  
  13. char* const container_args[] = { 
  14.     "/bin/bash", 
  15.     NULL 
  16. }; 
  17.  
  18. int container_main(void* arg) 
  19.     printf("Container - inside the container!\n"); 
  20.     /* 直接執(zhí)行一個shell,以便我們觀察這個進(jìn)程空間里的資源是否被隔離了 */ 
  21.     execv(container_args[0], container_args);  
  22.     printf("Something's wrong!\n"); 
  23.     return 1; 
  24.  
  25. int main() 
  26.     printf("Parent - start a container!\n"); 
  27.     /* 調(diào)用clone函數(shù),其中傳出一個函數(shù),還有一個??臻g的(為什么傳尾指針,因?yàn)闂J欠粗模?nbsp;*/ 
  28.     int container_pid = clone(container_main, container_stack+STACK_SIZE, SIGCHLD, NULL); 
  29.     /* 等待子進(jìn)程結(jié)束 */ 
  30.     waitpid(container_pid, NULL, 0); 
  31.     printf("Parent - container stopped!\n"); 
  32.     return 0; 

從上面的程序,我們可以看到,這和pthread基本上是一樣的玩法。但是,對于上面的程序,父子進(jìn)程的進(jìn)程空間是沒有什么差別的,父進(jìn)程能訪問到的子進(jìn)程也能。

下面, 讓我們來看幾個例子看看,Linux的Namespace是什么樣的。

UTS Namespace

下面的代碼,我略去了上面那些頭文件和數(shù)據(jù)結(jié)構(gòu)的定義,只有最重要的部分。

  1. int container_main(void* arg) 
  2.     printf("Container - inside the container!\n"); 
  3.     sethostname("container",10); /* 設(shè)置hostname */ 
  4.     execv(container_args[0], container_args); 
  5.     printf("Something's wrong!\n"); 
  6.     return 1; 
  7.  
  8. int main() 
  9.     printf("Parent - start a container!\n"); 
  10.     int container_pid = clone(container_main, container_stack+STACK_SIZE,  
  11.             CLONE_NEWUTS | SIGCHLD, NULL); /*啟用CLONE_NEWUTS Namespace隔離 */ 
  12.     waitpid(container_pid, NULL, 0); 
  13.     printf("Parent - container stopped!\n"); 
  14.     return 0; 

運(yùn)行上面的程序你會發(fā)現(xiàn)(需要root權(quán)限),子進(jìn)程的hostname變成了 container。

  1. hchen@ubuntu:~$ sudo ./uts 
  2. Parent - start a container! 
  3. Container - inside the container! 
  4. root@container:~# hostname 
  5. container 
  6. root@container:~# uname -n 
  7. container 

IPC Namespace

IPC全稱 Inter-Process Communication,是Unix/Linux下進(jìn)程間通信的一種方式,IPC有共享內(nèi)存、信號量、消息隊列等方法。所以,為了隔離,我們也需要把IPC給隔離開來,這樣,只有在同一個Namespace下的進(jìn)程才能相互通信。如果你熟悉IPC的原理的話,你會知道,IPC需要有一個全局的ID,即然是全局的,那么就意味著我們的Namespace需要對這個ID隔離,不能讓別的Namespace的進(jìn)程看到。

要啟動IPC隔離,我們只需要在調(diào)用clone時加上CLONE_NEWIPC參數(shù)就可以了。

  1. int container_pid = clone(container_main, container_stack+STACK_SIZE,  
  2.             CLONE_NEWUTS | CLONE_NEWIPC | SIGCHLD, NULL); 

首先,我們先創(chuàng)建一個IPC的Queue(如下所示,全局的Queue ID是0)

  1. hchen@ubuntu:~$ ipcmk -Q  
  2. Message queue id: 0 
  3.  
  4. hchen@ubuntu:~$ ipcs -q 
  5. ------ Message Queues -------- 
  6. key        msqid      owner      perms      used-bytes   messages     
  7. 0xd0d56eb2 0          hchen      644        0            0 

如果我們運(yùn)行沒有CLONE_NEWIPC的程序,我們會看到,在子進(jìn)程中還是能看到這個全啟的IPC Queue。

  1. hchen@ubuntu:~$ sudo ./uts  
  2. Parent - start a container! 
  3. Container - inside the container! 
  4.  
  5. root@container:~# ipcs -q 
  6.  
  7. ------ Message Queues -------- 
  8. key        msqid      owner      perms      used-bytes   messages     
  9. 0xd0d56eb2 0          hchen      644        0            0 

但是,如果我們運(yùn)行加上了CLONE_NEWIPC的程序,我們就會下面的結(jié)果:

  1. root@ubuntu:~$ sudo./ipc 
  2. Parent - start a container! 
  3. Container - inside the container! 
  4.  
  5. root@container:~/linux_namespace# ipcs -q 
  6.  
  7. ------ Message Queues -------- 
  8. key        msqid      owner      perms      used-bytes   messages 

我們可以看到IPC已經(jīng)被隔離了。

PID Namespace

我們繼續(xù)修改上面的程序:

  1. int container_main(void* arg) 
  2.     /* 查看子進(jìn)程的PID,我們可以看到其輸出子進(jìn)程的 pid 為 1 */ 
  3.     printf("Container [%5d] - inside the container!\n", getpid()); 
  4.     sethostname("container",10); 
  5.     execv(container_args[0], container_args); 
  6.     printf("Something's wrong!\n"); 
  7.     return 1; 
  8.  
  9. int main() 
  10.     printf("Parent [%5d] - start a container!\n", getpid()); 
  11.     /*啟用PID namespace - CLONE_NEWPID*/ 
  12.     int container_pid = clone(container_main, container_stack+STACK_SIZE,  
  13.             CLONE_NEWUTS | CLONE_NEWPID | SIGCHLD, NULL);  
  14.     waitpid(container_pid, NULL, 0); 
  15.     printf("Parent - container stopped!\n"); 
  16.     return 0; 

運(yùn)行結(jié)果如下(我們可以看到,子進(jìn)程的pid是1了):

  1. hchen@ubuntu:~$ sudo ./pid 
  2. Parent [ 3474] - start a container! 
  3. Container [    1] - inside the container! 
  4. root@container:~# echo $$ 

你可能會問,PID為1有個毛用啊?我們知道,在傳統(tǒng)的UNIX系統(tǒng)中,PID為1的進(jìn)程是init,地位非常特殊。他作為所有進(jìn)程的父進(jìn)程,有很多特權(quán)(比如:屏蔽信號等),另外,其還會為檢查所有進(jìn)程的狀態(tài),我們知道,如果某個子進(jìn)程脫離了父進(jìn)程(父進(jìn)程沒有wait它),那么init就會負(fù)責(zé)回收資源并結(jié)束這個子進(jìn)程。所以,要做到進(jìn)程空間的隔離,首先要創(chuàng)建出PID為1的進(jìn)程,最好就像chroot那樣,把子進(jìn)程的PID在容器內(nèi)變成1。

但是,我們會發(fā)現(xiàn),在子進(jìn)程的shell里輸入ps,top等命令,我們還是可以看得到所有進(jìn)程。說明并沒有完全隔離。這是因?yàn)?,像ps, top這些命令會去讀/proc文件系統(tǒng),所以,因?yàn)?proc文件系統(tǒng)在父進(jìn)程和子進(jìn)程都是一樣的,所以這些命令顯示的東西都是一樣的。

所以,我們還需要對文件系統(tǒng)進(jìn)行隔離。

Mount Namespace

下面的例程中,我們在啟用了mount namespace并在子進(jìn)程中重新mount了/proc文件系統(tǒng)。

  1. int container_main(void* arg) 
  2.     printf("Container [%5d] - inside the container!\n", getpid()); 
  3.     sethostname("container",10); 
  4.     /* 重新mount proc文件系統(tǒng)到 /proc下 */ 
  5.     system("mount -t proc proc /proc"); 
  6.     execv(container_args[0], container_args); 
  7.     printf("Something's wrong!\n"); 
  8.     return 1; 
  9.  
  10. int main() 
  11.     printf("Parent [%5d] - start a container!\n", getpid()); 
  12.     /* 啟用Mount Namespace - 增加CLONE_NEWNS參數(shù) */ 
  13.     int container_pid = clone(container_main, container_stack+STACK_SIZE,  
  14.             CLONE_NEWUTS | CLONE_NEWPID | CLONE_NEWNS | SIGCHLD, NULL); 
  15.     waitpid(container_pid, NULL, 0); 
  16.     printf("Parent - container stopped!\n"); 
  17.     return 0; 

運(yùn)行結(jié)果如下:

  1. hchen@ubuntu:~$ sudo ./pid.mnt 
  2. Parent [ 3502] - start a container! 
  3. Container [    1] - inside the container! 
  4. root@container:~# ps -elf  
  5. F S UID        PID  PPID  C PRI  NI ADDR SZ WCHAN  STIME TTY          TIME CMD 
  6. 4 S root         1     0  0  80   0 -  6917 wait   19:55 pts/2    00:00:00 /bin/bash 
  7. 0 R root        14     1  0  80   0 -  5671 -      19:56 pts/2    00:00:00 ps -elf 

上面,我們可以看到只有兩個進(jìn)程 ,而且pid=1的進(jìn)程是我們的/bin/bash。我們還可以看到/proc目錄下也干凈了很多:

  1. root@container:~# ls /proc 
  2. 1          dma          key-users   net            sysvipc 
  3. 16         driver       kmsg        pagetypeinfo   timer_list 
  4. acpi       execdomains  kpagecount  partitions     timer_stats 
  5. asound     fb           kpageflags  sched_debug    tty 
  6. buddyinfo  filesystems  loadavg     schedstat      uptime 
  7. bus        fs           locks       scsi           version 
  8. cgroups    interrupts   mdstat      self           version_signature 
  9. cmdline    iomem        meminfo     slabinfo       vmallocinfo 
  10. consoles   ioports      misc        softirqs       vmstat 
  11. cpuinfo    irq          modules     stat           zoneinfo 
  12. crypto     kallsyms     mounts      swaps 
  13. devices    kcore        mpt         sys 
  14. diskstats  keys         mtrr        sysrq-trigger 

下圖,我們也可以看到在子進(jìn)程中的top命令只看得到兩個進(jìn)程了。

 

 

這里,多說一下。在通過CLONE_NEWNS創(chuàng)建mount namespace后,父進(jìn)程會把自己的文件結(jié)構(gòu)復(fù)制給子進(jìn)程中。而子進(jìn)程中新的namespace中的所有mount操作都只影響自身的文件系統(tǒng),而不對外界產(chǎn)生任何影響。這樣可以做到比較嚴(yán)格地隔離。

你可能會問,我們是不是還有別的一些文件系統(tǒng)也需要這樣mount? 是的。

Docker的 Mount Namespace

下面我將向演示一個“山寨鏡像”,其模仿了Docker的Mount Namespace。

首先,我們需要一個rootfs,也就是我們需要把我們要做的鏡像中的那些命令什么的copy到一個rootfs的目錄下,我們模仿Linux構(gòu)建如下的目錄:

  1. hchen@ubuntu:~/rootfs$ ls 
  2. bin  dev  etc  home  lib  lib64  mnt  opt  proc  root  run  sbin  sys  tmp  usr  var 

然后,我們把一些我們需要的命令copy到 rootfs/bin目錄中(sh命令必需要copy進(jìn)去,不然我們無法 chroot )

  1. hchen@ubuntu:~/rootfs$ ls ./bin ./usr/bin 
  2.   
  3. ./bin: 
  4. bash   chown  gzip      less  mount       netstat  rm     tabs  tee      top       tty 
  5. cat    cp     hostname  ln    mountpoint  ping     sed    tac   test     touch     umount 
  6. chgrp  echo   ip        ls    mv          ps       sh     tail  timeout  tr        uname 
  7. chmod  grep   kill      more  nc          pwd      sleep  tar   toe      truncate  which 
  8.  
  9. ./usr/bin: 
  10. awk  env  groups  head  id  mesg  sort  strace  tail  top  uniq  vi  wc  xargs 

注:你可以使用ldd命令把這些命令相關(guān)的那些so文件copy到對應(yīng)的目錄:

  1. hchen@ubuntu:~/rootfs/bin$ ldd bash 
  2.     linux-vdso.so.1 =>  (0x00007fffd33fc000) 
  3.     libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f4bd42c2000) 
  4.     libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4bd40be000) 
  5.     libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4bd3cf8000) 
  6.     /lib64/ld-linux-x86-64.so.2 (0x00007f4bd4504000) 

下面是我的rootfs中的一些so文件:

  1. hchen@ubuntu:~/rootfs$ ls ./lib64 ./lib/x86_64-linux-gnu/ 
  2.  
  3. ./lib64: 
  4. ld-linux-x86-64.so.2 
  5.  
  6. ./lib/x86_64-linux-gnu/: 
  7. libacl.so.1      libmemusage.so         libnss_files-2.19.so    libpython3.4m.so.1 
  8. libacl.so.1.1.0  libmount.so.1          libnss_files.so.2       libpython3.4m.so.1.0 
  9. libattr.so.1     libmount.so.1.1.0      libnss_hesiod-2.19.so   libresolv-2.19.so 
  10. libblkid.so.1    libm.so.6              libnss_hesiod.so.2      libresolv.so.2 
  11. libc-2.19.so     libncurses.so.5        libnss_nis-2.19.so      libselinux.so.1 
  12. libcap.a         libncurses.so.5.9      libnss_nisplus-2.19.so  libtinfo.so.5 
  13. libcap.so        libncursesw.so.5       libnss_nisplus.so.2     libtinfo.so.5.9 
  14. libcap.so.2      libncursesw.so.5.9     libnss_nis.so.2         libutil-2.19.so 
  15. libcap.so.2.24   libnsl-2.19.so         libpcre.so.3            libutil.so.1 
  16. libc.so.6        libnsl.so.1            libprocps.so.3          libuuid.so.1 
  17. libdl-2.19.so    libnss_compat-2.19.so  libpthread-2.19.so      libz.so.1 
  18. libdl.so.2       libnss_compat.so.2     libpthread.so.0 
  19. libgpm.so.2      libnss_dns-2.19.so     libpython2.7.so.1 
  20. libm-2.19.so     libnss_dns.so.2        libpython2.7.so.1.0 

包括這些命令依賴的一些配置文件:

  1. hchen@ubuntu:~/rootfs$ ls ./etc 
  2. bash.bashrc  group  hostname  hosts  ld.so.cache  nsswitch.conf  passwd  profile   
  3. resolv.conf  shadow 

你現(xiàn)在會說,我靠,有些配置我希望是在容器起動時給他設(shè)置的,而不是hard code在鏡像中的。比如:/etc/hosts,/etc/hostname,還有DNS的/etc/resolv.conf文件。好的。那我們在rootfs外面,我們再創(chuàng)建一個conf目錄,把這些文件放到這個目錄中。

  1. hchen@ubuntu:~$ ls ./conf 
  2. hostname     hosts     resolv.conf 

這樣,我們的父進(jìn)程就可以動態(tài)地設(shè)置容器需要的這些文件的配置, 然后再把他們mount進(jìn)容器,這樣,容器的鏡像中的配置就比較靈活了。

好了,終于到了我們的程序。

  1. #define _GNU_SOURCE 
  2. #include <sys/types.h> 
  3. #include <sys/wait.h> 
  4. #include <sys/mount.h> 
  5. #include <stdio.h> 
  6. #include <sched.h> 
  7. #include <signal.h> 
  8. #include <unistd.h> 
  9.  
  10. #define STACK_SIZE (1024 * 1024) 
  11.  
  12. static char container_stack[STACK_SIZE]; 
  13. char* const container_args[] = { 
  14.     "/bin/bash", 
  15.     "-l", 
  16.     NULL 
  17. }; 
  18.  
  19. int container_main(void* arg) 
  20.     printf("Container [%5d] - inside the container!\n", getpid()); 
  21.  
  22.     //set hostname 
  23.     sethostname("container",10); 
  24.  
  25.     //remount "/proc" to make sure the "top" and "ps" show container's information 
  26.     if (mount("proc", "rootfs/proc", "proc", 0, NULL) !=0 ) { 
  27.         perror("proc"); 
  28.     } 
  29.     if (mount("sysfs", "rootfs/sys", "sysfs", 0, NULL)!=0) { 
  30.         perror("sys"); 
  31.     } 
  32.     if (mount("none", "rootfs/tmp", "tmpfs", 0, NULL)!=0) { 
  33.         perror("tmp"); 
  34.     } 
  35.     if (mount("udev", "rootfs/dev", "devtmpfs", 0, NULL)!=0) { 
  36.         perror("dev"); 
  37.     } 
  38.     if (mount("devpts", "rootfs/dev/pts", "devpts", 0, NULL)!=0) { 
  39.         perror("dev/pts"); 
  40.     } 
  41.     if (mount("shm", "rootfs/dev/shm", "tmpfs", 0, NULL)!=0) { 
  42.         perror("dev/shm"); 
  43.     } 
  44.     if (mount("tmpfs", "rootfs/run", "tmpfs", 0, NULL)!=0) { 
  45.         perror("run"); 
  46.     } 
  47.     /*  
  48.      * 模仿Docker的從外向容器里mount相關(guān)的配置文件  
  49.      * 你可以查看:/var/lib/docker/containers/<container_id>/目錄, 
  50.      * 你會看到docker的這些文件的。 
  51.      */ 
  52.     if (mount("conf/hosts", "rootfs/etc/hosts", "none", MS_BIND, NULL)!=0 || 
  53.           mount("conf/hostname", "rootfs/etc/hostname", "none", MS_BIND, NULL)!=0 || 
  54.           mount("conf/resolv.conf", "rootfs/etc/resolv.conf", "none", MS_BIND, NULL)!=0 ) { 
  55.         perror("conf"); 
  56.     } 
  57.     /* 模仿docker run命令中的 -v, --volume=[] 參數(shù)干的事 */ 
  58.     if (mount("/tmp/t1", "rootfs/mnt", "none", MS_BIND, NULL)!=0) { 
  59.         perror("mnt"); 
  60.     } 
  61.  
  62.     /* chroot 隔離目錄 */ 
  63.     if ( chdir("./rootfs") != 0 || chroot("./") != 0 ){ 
  64.         perror("chdir/chroot"); 
  65.     } 
  66.  
  67.     execv(container_args[0], container_args); 
  68.     perror("exec"); 
  69.     printf("Something's wrong!\n"); 
  70.     return 1; 
  71.  
  72. int main() 
  73.     printf("Parent [%5d] - start a container!\n", getpid()); 
  74.     int container_pid = clone(container_main, container_stack+STACK_SIZE,  
  75.             CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWPID | CLONE_NEWNS | SIGCHLD, NULL); 
  76.     waitpid(container_pid, NULL, 0); 
  77.     printf("Parent - container stopped!\n"); 
  78.     return 0; 

sudo運(yùn)行上面的程序,你會看到下面的掛載信息以及一個所謂的“鏡像”:

  1. hchen@ubuntu:~$ sudo ./mount  
  2. Parent [ 4517] - start a container! 
  3. Container [    1] - inside the container! 
  4. root@container:/# mount 
  5. proc on /proc type proc (rw,relatime) 
  6. sysfs on /sys type sysfs (rw,relatime) 
  7. none on /tmp type tmpfs (rw,relatime) 
  8. udev on /dev type devtmpfs (rw,relatime,size=493976k,nr_inodes=123494,mode=755
  9. devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000
  10. tmpfs on /run type tmpfs (rw,relatime) 
  11. /dev/disk/by-uuid/18086e3b-d805-4515-9e91-7efb2fe5c0e2 on /etc/hosts type ext4 (rw,relatime,errors=remount-ro,data=ordered
  12. /dev/disk/by-uuid/18086e3b-d805-4515-9e91-7efb2fe5c0e2 on /etc/hostname type ext4 (rw,relatime,errors=remount-ro,data=ordered
  13. /dev/disk/by-uuid/18086e3b-d805-4515-9e91-7efb2fe5c0e2 on /etc/resolv.conf type ext4 (rw,relatime,errors=remount-ro,data=ordered
  14.  
  15. root@container:/# ls /bin /usr/bin 
  16. /bin: 
  17. bash   chmod  echo  hostname  less  more    mv   ping  rm   sleep  tail  test     top    truncate  uname 
  18. cat    chown  grep  ip        ln    mount   nc   ps    sed  tabs   tar   timeout  touch  tty       which 
  19. chgrp  cp     gzip  kill      ls    mountpoint  netstat  pwd   sh   tac    tee   toe      tr     umount 
  20.  
  21. /usr/bin: 
  22. awk  env  groups  head  id  mesg  sort  strace  tail  top  uniq  vi  wc  xargs 

關(guān)于如何做一個chroot的目錄,這里有個工具叫DebootstrapChroot,你可以順著鏈接去看看(英文的哦)

接下來的事情,你可以自己玩了,我相信你的想像力 。:)

今天的內(nèi)容就介紹到這里,在Docker 基礎(chǔ)技術(shù):Linux Namespace(下篇)中,我將向你介紹User Namespace、Network Namespace以及Namespace的其它東西。

責(zé)任編輯:趙寧寧 來源: H2EX
相關(guān)推薦

2016-09-20 22:04:55

Docker Linux Names

2021-07-10 08:29:13

Docker內(nèi)核Namespace

2021-07-14 10:33:22

Docker內(nèi)核Mount Names

2022-08-04 07:25:22

Docker部署項(xiàng)目

2012-03-18 21:41:40

linux虛擬化

2023-11-09 16:13:53

2015-08-26 11:27:26

DockerDeviceMappe分層鏡像

2018-02-26 08:14:20

LinuxDocker容器

2013-10-30 11:27:25

Linux基礎(chǔ)網(wǎng)絡(luò)設(shè)備

2018-06-03 09:26:58

云計算數(shù)據(jù)技術(shù)層

2022-10-30 15:00:50

2014-05-07 09:56:48

Docker管理Linux容器

2014-05-07 10:04:57

DockerLinux容器Ubuntu

2014-09-18 14:13:54

Docker

2022-08-30 19:11:12

Docker虛擬化技術(shù)

2021-03-05 18:36:00

Linux網(wǎng)橋Docker

2014-07-07 09:49:13

UbuntuDocker

2009-12-25 10:05:00

Linux虛擬化Xen虛擬化

2009-06-13 09:22:41

Linux虛擬化Xen

2022-07-26 07:14:52

Docker宿主命令
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號