尊龙凯时人生就是搏

ÔõÑùÔÚLinuxЧÀÍÆ÷ÉϽ¨Éè¸ßЧµÄDocker¾µÏñ¿ÍÕ»£¿

ÔõÑùÔÚlinuxЧÀÍÆ÷ÉϽ¨Éè¸ßЧµÄdocker¾µÏñ¿ÍÕ»£¿

Ëæ×ÅÈÝÆ÷»¯ÊÖÒÕµÄÉú³¤ºÍÆÕ¼°£¬DockerÒѳÉΪ×îÊ¢ÐеÄÈÝÆ÷»¯½â¾ö¼Æ»®Ö®Ò»¡£ÔÚʹÓÃDocker¹¹½¨ºÍÖÎÀí´ó¹æÄ£µÄÓ¦ÓóÌÐòʱ£¬¸ßЧµÄDocker¾µÏñ¿ÍÕ»ÊǺÜÊÇÖ÷ÒªµÄ¡£Ëü²»µ«¿ÉÒÔ¼ÓËÙ°²ÅźÍÀ©Õ¹Àú³Ì£¬»¹¿ÉÒÔÌá¸ß¿ª·¢ÕßµÄÊÂÇéЧÂÊ¡£ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝÔõÑùÔÚLinuxЧÀÍÆ÷ÉϽ¨Éè¸ßЧµÄDocker¾µÏñ¿ÍÕ»£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

×°ÖÃDockerºÍDocker Registry

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚLinuxЧÀÍÆ÷ÉÏ×°ÖÃDockerºÍDocker Registry¡£Docker¿ÉÒÔͨ¹ý¹Ù·½µÄ×°Öþ籾¾ÙÐÐ×°Öã¬ÏêϸÀú³ÌÇë²Î¿¼DockerµÄ¹Ù·½Îĵµ¡£×°ÖÃÍêDockerºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁî×°ÖÃDocker Registry£º

$ docker run -d -p 5000:5000 --restart=always --name registry registry:2

µÇ¼ºó¸´ÖÆ

´ËÏÂÁÔÚЧÀÍÆ÷ÉÏÆô¶¯Ò»¸öDocker RegistryÈÝÆ÷£¬²¢½«ÈÝÆ÷ÖеÄ5000¶Ë¿ÚÓ³É䵽ЧÀÍÆ÷µÄ5000¶Ë¿Ú¡£

ÉèÖÃDocker Registry

×°ÖÃÍêDocker Registryºó£¬ÎÒÃÇÐèÒª¾ÙÐÐһЩÉèÖòŻªÊ¹Æä¸ü¸ßЧ¡£Ê×ÏÈ£¬ÎÒÃÇÐèÒªÐÞ¸ÄDockerµÄÉèÖÃÎļþ£¬ÒÔ±ãÔÊÐí²»Çå¾²µÄ¾µÏñ´«Êä¡£±à¼­/etc/docker/daemon.jsonÎļþ£¬Ìí¼ÓÒÔÏÂÄÚÈÝ£º

{
  "insecure-registries" : ["your-registry-url:5000"]
}

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬your-registry-urlÊÇÄãµÄ¾µÏñ¿ÍÕ»µÄURL£¨ÀýÈ磺my-registry.com£©¡£

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÖØмÓÔØDockerµÄÉèÖÃÎļþ£¬ÒÔʹ¸ü¸ÄÉúЧ£º

$ systemctl daemon-reload
$ systemctl restart docker

µÇ¼ºó¸´ÖÆ

½¨ÉèºÍÉÏ´«¾µÏñ

ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔ½¨ÉèDocker¾µÏñ²¢ÉÏ´«µ½ÎÒÃǵľµÏñ¿ÍÕ»ÖÐÁË¡£Ê×ÏÈ£¬ÎÒÃÇÐèÒª¹¹½¨Ò»¸öDocker¾µÏñ¡£ÒÔÏÂÊÇÒ»¸öʾÀýµÄDockerfileÎļþ£º

FROM ubuntu:latest
RUN apt-get update && apt-get install -y python3
COPY app.py /app.py
CMD ["python3", "/app.py"]

µÇ¼ºó¸´ÖÆ

ÔÚͳһĿ¼Ï½¨ÉèÒ»¸öÃûΪapp.pyµÄÎļþ£¬²¢Ìí¼ÓһЩ´úÂë¡£Ö®ºó£¬Ê¹ÓÃÒÔÏÂÏÂÁî¹¹½¨¾µÏñ£º

$ docker build -t your-registry-url:5000/my-image:1.0 .

µÇ¼ºó¸´ÖÆ

½«your-registry-urlÌ滻ΪÄãµÄ¾µÏñ¿ÍÕ»µÄURL¡£

¹¹½¨Íê³Éºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ¾µÏñÉÏ´«µ½¾µÏñ¿ÍÕ»ÖУº

$ docker push your-registry-url:5000/my-image:1.0

µÇ¼ºó¸´ÖÆ

Õ⽫»á½«¹¹½¨ºÃµÄ¾µÏñÍÆË͵½ÎÒÃǵľµÏñ¿ÍÕ»ÖС£

´Ó¾µÏñ¿ÍÕ»ÖÐÀ­È¡¾µÏñ

µ±ÎÒÃÇÐèÒªÔÚÆäËûЧÀÍÆ÷ÉÏ°²ÅÅÎÒÃǵÄÓ¦ÓÃʱ£¬¿ÉÒÔ´Ó¾µÏñ¿ÍÕ»ÖÐÀ­È¡ËùÐèµÄ¾µÏñ¡£ÒÔÏÂÊÇÀ­È¡¾µÏñµÄÏÂÁ

$ docker pull your-registry-url:5000/my-image:1.0

µÇ¼ºó¸´ÖÆ

Õ⽫»á´Ó¾µÏñ¿ÍÕ»ÖÐÀ­È¡¶ÔÓ¦°æ±¾µÄ¾µÏñ¡£

ʹÓÃ˽ÓоµÏñ¿ÍÕ»

ΪÁ˱£»¤ÎÒÃǵÄÓ¦ÓúÍÊý¾ÝÇå¾²£¬ÎÒÃÇ¿ÉÒÔʹÓûá¼û¿ØÖÆÀ´ÏÞÖƶÔÎÒÃǵÄ˽ÓоµÏñ¿ÍÕ»µÄ»á¼û¡£ÒÔÏÂÊÇÒ»ÖÖʹÓûù×Ô¼º·ÝÑéÖ¤£¨Basic Authentication£©·½·¨À´¿ØÖÆ»á¼ûµÄʾÀý£º

Ê×ÏÈ£¬ÎÒÃÇÐèÒª½¨ÉèÒ»¸öÃÜÂëÎļþ£¬ÓÃÓÚ´æ´¢Óû§ÃûºÍÃÜÂ롣ʹÓÃÒÔÏÂÏÂÁÉèÃÜÂëÎļþ£º

$ docker run --rm --entrypoint htpasswd registry:2 -Bbn your-username your-password > auth/htpasswd

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬your-usernameºÍyour-passwordÊÇÄãËù½ç˵µÄÓû§ÃûºÍÃÜÂë¡£

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒªÐÞ¸ÄDocker RegistryµÄÆô¶¯ÏÂÁָ¶¨Ê¹Óûá¼û¿ØÖÆÉèÖá£Ê¹ÓÃÒÔÏÂÏÂÁîÆô¶¯Docker RegistryÈÝÆ÷£º

$ docker run -d -p 5000:5000 --restart=always --name registry 
             -v /path/to/auth:/auth 
             -e "REGISTRY_AUTH=htpasswd" 
             -e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" 
             -e "REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd" 
             registry:2

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬½«/path/to/authÌ滻ΪÄãËù´æ´¢ÃÜÂëÎļþµÄ·¾¶¡£

ÏÖÔÚ£¬ÄãµÄ˽ÓоµÏñ¿ÍÕ»ÒѾ­ÉèÖÃÁË»ù×Ô¼º·ÝÑéÖ¤£¬Ö»Óо­ÓÉÊÚȨµÄÓû§²Å»ª¹»»á¼û¡£

×ܽá

ÔÚ±¾ÎÄÖУ¬ÎÒÃÇÏÈÈÝÁËÔõÑùÔÚLinuxЧÀÍÆ÷ÉϽ¨Éè¸ßЧµÄDocker¾µÏñ¿ÍÕ»¡£ÎÒÃÇÊ×ÏÈ×°Öò¢ÉèÖÃÁËDockerºÍDocker Registry£¬È»ºóͨ¹ý¹¹½¨ºÍÉÏ´«¾µÏñµÄʾÀýÑÝʾÁËÔõÑùʹÓþµÏñ¿ÍÕ»¡£×îºó£¬ÎÒÃÇÏÈÈÝÁËÔõÑùʹÓûù×Ô¼º·ÝÑéÖ¤À´±£»¤¾µÏñ¿ÍÕ»µÄÇå¾²¡£

ͨ¹ý½¨Éè¸ßЧµÄDocker¾µÏñ¿ÍÕ»£¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÖÎÀíºÍ°²ÅÅ´ó¹æÄ£µÄÓ¦ÓóÌÐò£¬Ìá¸ß¿ª·¢ºÍÔËάЧÂÊ¡£Ï£Íû±¾ÎĶÔÄãÓÐËù×ÊÖú£¬²¢Äܹ»ÔÚÏÖʵӦÓÃÖÐÊ©Õ¹×÷Óá£

ÒÔÉϾÍÊÇÔõÑùÔÚLinuxЧÀÍÆ÷ÉϽ¨Éè¸ßЧµÄDocker¾µÏñ¿ÍÕ»£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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