×ðÁú¿­Ê±¹ÙÍøµÇ¼

ÔõÑù¾ÙÐÐLinuxϵͳµÄÈÝÆ÷»¯°²ÅźÍÖÎÀí

ÔõÑù¾ÙÐÐLinuxϵͳµÄÈÝÆ÷»¯°²ÅźÍÖÎÀí

Ëæ×ÅÔÆÅÌËãºÍ΢ЧÀͼܹ¹µÄÐËÆ𠣬ÈÝÆ÷»¯ÊÖÒÕ³ÉΪÁËÈí¼þ¿ª·¢ºÍ°²ÅŵÄÖ÷Òª¹¤¾ß¡£LinuxϵͳÉϵÄÈÝÆ÷»¯°²ÅźÍÖÎÀí¼Æ»® £¬ÈçDockerºÍKubernetes £¬ÒѾ­±»ÆÕ±é½ÓÄÉ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDocker¾ÙÐÐÈÝÆ÷»¯°²ÅźÍÖÎÀí £¬²¢¸ø³öÏêϸµÄ´úÂëʾÀý¡£

×°ÖÃDocker

Ê×ÏÈ £¬ÐèÒªÔÚLinuxϵͳÉÏ×°ÖÃDocker¡ £¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÀ´×°ÖÃDocker£º

$ sudo apt-get update
$ sudo apt-get install docker.io

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÑéÖ¤DockerÊÇ·ñ×°ÖÃÀֳɣº

$ docker --version

µÇ¼ºó¸´ÖÆ

½¨ÉèDocker¾µÏñ

Docker¾µÏñÊÇÓÃÀ´½¨ÉèDockerÈÝÆ÷µÄÄ£°å¡ £¿ÉÒÔͨ¹ýDockerfileÀ´½ç˵¾µÏñµÄÄÚÈݺÍÉèÖá£ÒÔÏÂÊÇÒ»¸ö¼òÆÓµÄDockerfileʾÀý£º

# ʹÓûù´¡¾µÏñ
FROM ubuntu:16.04

# ×°ÖÃËùÐèÈí¼þ°ü
RUN apt-get update && apt-get install -y 
    nginx 
    php7.2 
    mysql-server

# ¸´ÖÆÉèÖÃÎļþµ½¾µÏñÖÐ
COPY nginx.conf /etc/nginx/nginx.conf
COPY index.php /var/www/html/index.php

# ÈÝÆ÷Æô¶¯Ê±ÔËÐеÄÏÂÁî
CMD ["nginx", "-g", "daemon off;"]

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÀýÖÐ £¬Ê×ÏÈʹÓÃÁËÒ»¸ö»ù´¡¾µÏñ ubuntu:16.04 £¬È»ºó×°ÖÃÁ˼¸¸öÈí¼þ°ü £¬¸´ÖÆÁËÉèÖÃÎļþºÍÓ¦ÓóÌÐò´úÂë £¬×îºóÉèÖÃÁËÈÝÆ÷Æô¶¯Ê±ÔËÐеÄÏÂÁî¡£

¹¹½¨ºÍÔËÐÐÈÝÆ÷

¹¹½¨¾µÏñµÄÏÂÁîÊÇ docker build £¬Í¨¹ýÖ¸¶¨Ä¿Â¼ºÍDockerfile·¾¶À´Íê³É¡£ÀýÈç £¬ÔÚÄ¿½ñĿ¼ÏÂÔËÐÐÒÔÏÂÏÂÁ

$ docker build -t myapp .

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁ»á¹¹½¨Ò»¸öÃûΪ myapp µÄ¾µÏñ¡£

½ÓÏÂÀ´ £¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÔËÐоµÏñ½¨ÉèÈÝÆ÷£º

$ docker run -d -p 80:80 myapp

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁîÖÐ £¬²ÎÊý -d ÌåÏÖÒÔºǫ́ģʽÔËÐÐ £¬-p 80:80 ÌåÏÖ½«Ö÷»úµÄ80¶Ë¿ÚÓ³Éäµ½ÈÝÆ÷µÄ80¶Ë¿Ú¡£

ÈÝÆ÷ÖÎÀí

ͨ¹ýDockerÏÂÁîÀ´ÖÎÀíÈÝÆ÷¡£ÒÔÏÂÊÇһЩ³£ÓõÄÏÂÁîʾÀý£º

Éó²éËùÓÐÕýÔÚÔËÐеÄÈÝÆ÷£º

$ docker ps

µÇ¼ºó¸´ÖÆ

Éó²éËùÓÐÈÝÆ÷£¨°üÀ¨ÒÑ×èÖ¹µÄ£©£º

$ docker ps -a

µÇ¼ºó¸´ÖÆ

×èÖ¹Ò»¸öÈÝÆ÷£º

$ docker stop <ÈÝÆ÷ID>

µÇ¼ºó¸´ÖÆ

Æô¶¯Ò»¸öÈÝÆ÷£º

$ docker start <ÈÝÆ÷ID>

µÇ¼ºó¸´ÖÆ

½øÈëÒ»¸öÈÝÆ÷µÄshellÇéÐΣº

$ docker exec -it <ÈÝÆ÷ID> /bin/bash

µÇ¼ºó¸´ÖÆ

ɾ³ýÒ»¸öÈÝÆ÷£º

$ docker rm <ÈÝÆ÷ID>

µÇ¼ºó¸´ÖÆ

Éó²éÈÝÆ÷ÈÕÖ¾£º

$ docker logs <ÈÝÆ÷ID>

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÖ»ÊÇһЩ³£¼ûµÄÏÂÁîʾÀý £¬Docker»¹ÌṩÁËÐí¶àÆäËû¹¦Ð§ºÍÏÂÁî £¬¿ÉÒÔƾ֤ÏêϸÐèÇó¾ÙÐÐѧϰºÍʹÓá£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃDocker¾ÙÐÐLinuxϵͳµÄÈÝÆ÷»¯°²ÅźÍÖÎÀí £¬²¢¸ø³öÁËÏêϸµÄ´úÂëʾÀý¡£Í¨¹ýѧϰºÍÕÆÎÕÕâЩ֪ʶ £¬¿ÉÒÔ¸üÓÐÓõؾÙÐÐÈí¼þ¿ª·¢ºÍ°²ÅÅ £¬Ìá¸ßÊÂÇéЧÂʺÍϵͳÎȹÌÐÔ¡£Ï£Íû±¾ÎĶԶÁÕßÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇÔõÑù¾ÙÐÐLinuxϵͳµÄÈÝÆ÷»¯°²ÅźÍÖÎÀíµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ