尊龙凯时人生就是博

LinuxϵÄDocker£ºÔõÑù°ü¹ÜÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ£¿

linuxϵÄdocker£ºÔõÑù°ü¹ÜÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ£¿

Ëæ×ÅÔÆÅÌËãºÍÈÝÆ÷ÊÖÒյĿìËÙÉú³¤ £¬DockerÒѾ­³ÉΪÁËÒ»¸öºÜÊÇÊ¢ÐеÄÈÝÆ÷»¯Æ½Ì¨¡£Docker²»µ«ÌṩÁËÇáÁ¿¼¶¡¢¿ÉÒÆÖ²ºÍ¿ÉÀ©Õ¹µÄÈÝÆ÷ÇéÐÎ £¬²¢ÇÒ»¹¾ß±¸ÓÅÒìµÄÇå¾²ÐԺ͸ôÀëÐÔ¡£±¾ÎĽ«ÏÈÈÝÔÚLinuxϵͳÏÂÔõÑù°ü¹ÜDockerÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ £¬²¢¸ø³öһЩÏà¹ØµÄ´úÂëʾÀý¡£

ʹÓÃ×îеÄDocker°æ±¾

DockerÊÇÒ»¸ö»îÔ¾µÄ¿ªÔ´ÏîÄ¿ £¬Ã¿¸ö°æ±¾¶¼»áÐÞ¸´Ò»Ð©Çå¾²Îó²îºÍÎÊÌâ¡£Òò´Ë £¬ÎªÁË°ü¹ÜÈÝÆ÷µÄÇå¾²ÐÔ £¬ÎÒÃÇÓ¦¸ÃʼÖÕʹÓÃ×îеÄDocker°æ±¾¡£ÔÚUbuntuϵͳÉÏ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´×°ÖÃ×îеÄDocker°æ±¾£º

sudo apt-get update
sudo apt-get install docker-ce

µÇ¼ºó¸´ÖÆ

ÉèÖÃDockerµÄÇ徲ѡÏî

DockerÌṩÁËһЩÇ徲ѡÏî £¬¿ÉÒÔÉèÖÃÈÝÆ÷µÄ¸ôÀ뼶±ðºÍȨÏÞ¡£ÔÚDockerµÄÉèÖÃÎļþÖÐ £¬¿ÉÒÔÉèÖÃÒÔϵÄÑ¡Ï

# ÉèÖÃÈÝÆ÷µÄ¸ôÀ뼶±ð£¬ÍƼöʹÓÃĬÈÏÖµ
--security-opt seccomp=unconfined

# ½ûÓÃÈÝÆ÷µÄÍøÂ繦Ч£¬×èÖ¹ÈÝÆ÷±»ÓÃ×÷¹¥»÷ÆäËûÍøÂç×ÊÔ´
--security-opt no-new-privileges

# ÏÞÖÆÈÝÆ÷µÄϵͳŲÓÃȨÏÞ£¬×èÖ¹ÈÝÆ÷ÀÄÓÃϵͳ×ÊÔ´
--security-opt apparmor=docker-default

µÇ¼ºó¸´ÖÆ

¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´ÉèÖÃÕâЩѡÏî £¬ÒÔÌá¸ßÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ¡£

ʹÓý¡È«µÄ¾µÏñºÍÈÝÆ÷

DockerÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔÒ²ÓëËùʹÓõľµÏñºÍÈÝÆ÷×Ô¼ºÓйØ¡£ÎÒÃÇÓ¦¸ÃÑ¡ÔñÀ´×Ô¿É¿¿ÈªÔ´µÄ¾µÏñ £¬²¢È·±£ËüÃÇÊǾ­ÓÉÑéÖ¤ºÍרÃÅΪDockerÉè¼ÆµÄ¡£±ðµÄ £¬ÎÒÃÇ»¹Ó¦¸Ã°´ÆÚ¸üкÍÉý¼¶¾µÏñÖÐËùʹÓõÄÈí¼þ°üºÍÒÀÀµÏî £¬ÒÔïÔ̭DZÔÚµÄÇå¾²Îó²î¡£

ʹÓÃÇå¾²µÄÍøÂçÉèÖÃ

DockerÌṩÁ˶àÖÖÍøÂçÑ¡Ïî £¬¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´ÉèÖÃÈÝÆ÷µÄÍøÂ硣ΪÁË°ü¹ÜÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔϵÄÍøÂçÉèÖãº

# ʹÓÃÇŽÓÍøÂç£¬Ã¿¸öÈÝÆ÷¶¼ÓÐ×Ô¼ºµÄIPµØµã
--network bridge

# ÏÞÖÆÈÝÆ÷µÄÍøÂçÁ÷Á¿£¬Ö»ÔÊÐíÌض¨µÄ¶Ë¿ÚºÍЭÒé
--publish <host-port>:<container-port>/<protocol>

# ÉèÖÃÈÝÆ÷µÄÍøÂçÕ½ÂÔ£¬Ö»ÔÊÐíÓëÌض¨IPµØµã»òÍøÂç¾ÙÐÐͨѶ
--network-policy <ip-address>/<subnet>

µÇ¼ºó¸´ÖÆ

¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´ÉèÖÃÕâЩÍøÂçÑ¡Ïî £¬ÒÔÌá¸ßÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ¡£

ʹÓÃÈÝÆ÷µÄÏÞÖƺÍ×ÊÔ´¿ØÖÆ

LinuxϵͳÌṩÁËһЩ»úÖÆÀ´ÏÞÖƺͿØÖÆÀú³ÌµÄ×ÊԴʹÓá£ÎÒÃÇ¿ÉÒÔʹÓÃÕâЩ»úÖÆÀ´ÏÞÖƺͿØÖÆDockerÈÝÆ÷µÄ×ÊԴʹÓà £¬ÒÔ°ü¹ÜÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ¡£ÒÔÏÂÊÇһЩ³£ÓõÄ×ÊÔ´¿ØÖÆÑ¡Ï

# ÏÞÖÆÈÝÆ÷µÄCPUʹÓÃ
--cpu-shares <shares>

# ÏÞÖÆÈÝÆ÷µÄÄÚ´æʹÓÃ
--memory <memory-limit>

# ÏÞÖÆÈÝÆ÷µÄ´ÅÅÌʹÓÃ
--storage-opt size=<size-limit>

µÇ¼ºó¸´ÖÆ

¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´ÉèÖÃÕâЩ×ÊÔ´¿ØÖÆÑ¡Ïî £¬ÒÔÌá¸ßÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ¡£

×ÛÉÏËùÊö £¬°ü¹ÜDockerÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔÔÚLinuxϵͳÏÂÊǺÜÊÇÖ÷ÒªµÄ¡£Í¨¹ýʹÓÃ×îеÄDocker°æ±¾¡¢ÉèÖÃÇ徲ѡÏʹÓý¡È«µÄ¾µÏñºÍÈÝÆ÷¡¢Ê¹ÓÃÇå¾²µÄÍøÂçÉèÖÃÒÔ¼°Ê¹ÓÃÈÝÆ÷µÄÏÞÖƺÍ×ÊÔ´¿ØÖÆ £¬ÎÒÃÇ¿ÉÒÔÓÐÓõØÌá¸ßÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ¡£Òò´Ë £¬ÔÚʹÓÃDockerʱ £¬ÎñÐëÒª¹Ø×¢ÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ £¬²¢Æ¾Ö¤ÏÖʵÐèÇóÀ´¾ÙÐÐÏìÓ¦µÄÉèÖú͵÷ÓÅ¡£

£¨ÎÄÕÂͼÀý/ͼƬȪԴ£ºDocker¹Ù·½ÍøÕ¾£©

´úÂëʾÀý£º

# ½¨ÉèÒ»¸öÃûΪ"mycontainer"µÄÈÝÆ÷£¬²¢ÉèÖÃÇ徲ѡÏî
docker run --name mycontainer 
--security-opt seccomp=unconfined 
--security-opt no-new-privileges 
--security-opt apparmor=docker-default 
ubuntu:latest

µÇ¼ºó¸´ÖÆ

# ½«ÈÝÆ÷µÄ80¶Ë¿ÚÓ³Éäµ½Ö÷»úµÄ8080¶Ë¿Ú£¬²¢Æô¶¯ÈÝÆ÷
docker run -d -p 8080:80 nginx:latest

µÇ¼ºó¸´ÖÆ

# ÏÞÖÆÈÝÆ÷µÄCPUʹÓÃΪ50%
docker run --cpu-shares 512 mycontainer

µÇ¼ºó¸´ÖÆ

# ÏÞÖÆÈÝÆ÷µÄÄÚ´æʹÓÃΪ512MB
docker run --memory 512m mycontainer

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÊÇһЩDockerÈÝÆ÷µÄÏà¹ØÉèÖúÍÏÂÁîʾÀý £¬¿ÉÒÔƾ֤ÏÖʵÐèÇóÀ´Ê¹Óú͵÷½â¡£

ÒÔÉϾÍÊÇLinuxϵÄDocker£ºÔõÑù°ü¹ÜÈÝÆ÷µÄÇå¾²ÐԺ͸ôÀëÐÔ£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ