尊龙凯时人生就是博

ÔõÑùʹÓÃDockerÈÝÆ÷ÔÚLinuxÉϾÙÐÐÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ£¿

ÔõÑùʹÓÃdockerÈÝÆ÷ÔÚlinuxÉϾÙÐÐÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ£¿

ÔÚÈí¼þ¿ª·¢Àú³ÌÖÐ £¬Ò»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅÒѾ­³ÉΪһÖÖÇ÷ÊÆ¡£ËüÃDz»µ«Äܹ»¼ÓËÙÈí¼þ¿ª·¢ºÍÐû²¼µÄËÙÂÊ £¬»¹¿ÉÒÔÌá¸ßÈí¼þÖÊÁ¿¡£ÔÚLinuxϵͳÖÐ £¬Ê¹ÓÃDockerÈÝÆ÷¿ÉÒÔÇáËÉʵÏÖÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ £¬±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDockerÈÝÆ÷À´ÊµÏÖÕâһĿµÄ¡£

Ò»¡¢Ò»Á¬¼¯³É

Ò»Á¬¼¯³ÉÊÇÖ¸½«¿ª·¢Ö°Ô±µÄ´úÂëƵÈԵغϲ¢µ½Ö÷¸É´úÂëÖÐ £¬È»ºó×Ô¶¯¹¹½¨ºÍ²âÊÔ´úÂ롣ʹÓÃDockerÈÝÆ÷¿ÉÒÔΪÿ¸ö¿ª·¢Ö°Ô±½¨ÉèÒ»¸ö×ÔÁ¦µÄÔËÐÐÇéÐÎ £¬×èÖ¹ÁËÒÀÀµÐÔÎÊÌâ £¬ÒÔ¼°×èÖ¹ÁË´úÂëÖ®¼äµÄ³åÍ»¡£ÏÂÃæÊÇÒ»¸öʹÓÃDockerÈÝÆ÷¾ÙÐÐÒ»Á¬¼¯³ÉµÄʾÀý£º

×¼±¸DockerÇéÐÎ

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

sudo apt-get install docker-ce

µÇ¼ºó¸´ÖÆ

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

docker --version

µÇ¼ºó¸´ÖÆ

½¨ÉèDocker¾µÏñ

ÔÚÒ»Á¬¼¯³ÉÀú³ÌÖÐ £¬Ê×ÏÈÐèҪΪÿ¸öÏîÄ¿½¨ÉèÒ»¸öDocker¾µÏñ¡£Docker¾µÏñ°üÀ¨ÁËÏîÄ¿µÄÔËÐÐÇéÐκÍÒÀÀµÏî¡£ÔÚÏîÄ¿¸ùĿ¼Ï½¨ÉèÒ»¸öÃûΪDockerfileµÄÎļþ £¬²¢Ìí¼ÓÒÔÏÂÄÚÈÝ£º

FROM node:12
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÄÚÈÝÊÇÒ»¸öNode.jsÏîÄ¿µÄʾÀý £¬ÏêϸÄÚÈÝƾ֤ÏÖʵÐèÇó¾ÙÐÐÐ޸ġ£È»ºóʹÓÃÒÔÏÂÏÂÁîÀ´¹¹½¨Docker¾µÏñ£º

docker build -t myapp .

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬myappÊÇ×Ô½ç˵µÄ¾µÏñÃû³Æ¡£

±àд¹¹½¨¾ç±¾

ΪÁËʵÏÖÒ»Á¬¼¯³É £¬ÐèÒªÔÚ´úÂë¿ÍÕ»Öбàдһ¸ö¹¹½¨¾ç±¾¡£¸Ã¾ç±¾ÈÏÕæÀ­È¡×îеĴúÂë £¬¹¹½¨Docker¾µÏñ £¬²¢½«¾µÏñÍÆË͵½Docker¾µÏñ¿ÍÕ»¡£ÒÔÏÂÊÇÒ»¸ö¹¹½¨¾ç±¾µÄʾÀý£º

#!/bin/bash

# À­È¡×îеĴúÂë
git pull

# ¹¹½¨Docker¾µÏñ
docker build -t myapp .

# ÍÆË;µÏñµ½Docker¾µÏñ¿ÍÕ»
docker push myapp:latest

µÇ¼ºó¸´ÖÆ

¶þ¡¢Ò»Á¬°²ÅÅ

Ò»Á¬°²ÅÅÊÇÖ¸½«Í¨¹ýÒ»Á¬¼¯³É¹¹½¨µÄ¿ÉÖ´ÐÐÎļþ»òDocker¾µÏñ×Ô¶¯°²Åŵ½Éú²úÇéÐΡ£ÒÔÏÂÊÇÒ»¸öʹÓÃDockerÈÝÆ÷¾ÙÐÐÒ»Á¬°²ÅŵÄʾÀý£º

×¼±¸Éú²úÇéÐÎ

ÔÚÉú²úÇéÐÎÖÐ £¬Ê×ÏÈÐèҪװÖÃDockerºÍDocker Compose¡£¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁîÍê³É×°Öãº

sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo apt-get install docker-compose

µÇ¼ºó¸´ÖÆ

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

docker-compose --version

µÇ¼ºó¸´ÖÆ

±àдDocker ComposeÎļþ

ΪÁËʵÏÖÒ»Á¬°²ÅÅ £¬ÐèÒªÔÚÉú²úÇéÐÎÖбàдһ¸öDocker ComposeÎļþ¡£¸ÃÎļþ½ç˵ÁËÐèÒªÔËÐеÄDockerÈÝÆ÷ºÍÏà¹ØµÄÉèÖá£ÒÔÏÂÊÇÒ»¸öDocker ComposeÎļþµÄʾÀý£º

version: '3'
services:
  myapp:
    image: myapp:latest
    ports:
      - 8000:8000

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÄÚÈÝÊÇÒ»¸öWebÓ¦ÓóÌÐòµÄʾÀý £¬½«ÈÝÆ÷µÄ8000¶Ë¿ÚÓ³Éäµ½Ö÷»úµÄ8000¶Ë¿Ú¡£ÆäËûµÄÉèÖÿÉÒÔƾ֤ÏÖʵÐèÇó¾ÙÐÐÐ޸ġ£

±àд°²Åž籾

ΪÁËʵÏÖÒ»Á¬°²ÅÅ £¬ÐèÒªÔÚÉú²úÇéÐÎÖбàдһ¸ö°²Åž籾¡£¸Ã¾ç±¾ÈÏÕæÀ­È¡×îеİ汾µÄDocker¾µÏñ £¬²¢Ê¹ÓÃDocker ComposeÀ´Æô¶¯ÈÝÆ÷¡£ÒÔÏÂÊÇÒ»¸ö°²Åž籾µÄʾÀý£º

#!/bin/bash

# À­È¡×îеİ汾µÄ¾µÏñ
docker pull myapp:latest

# ʹÓÃDocker ComposeÆô¶¯ÈÝÆ÷
docker-compose up -d

µÇ¼ºó¸´ÖÆ

ͨ¹ýÒÔÉÏ°ì·¨ £¬¾Í¿ÉÒÔʹÓÃDockerÈÝÆ÷ÔÚLinuxÉÏʵÏÖÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ¡£ÕâÖÖ·½·¨¿ÉÒÔ´ó´ó¼ò»¯Èí¼þ¿ª·¢ºÍÐû²¼µÄÁ÷³Ì £¬Ìá¸ßÊÂÇéЧÂÊ¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃDockerÈÝÆ÷ÔÚLinuxÉϾÙÐÐÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ¡£Í¨¹ýʹÓÃDockerÈÝÆ÷ £¬¿ÉÒÔΪÿ¸ö¿ª·¢Ö°Ô±½¨Éè×ÔÁ¦µÄÔËÐÐÇéÐÎ £¬×èÖ¹ÁËÒÀÀµÐÔÎÊÌ⡣ͬʱ £¬Ê¹ÓÃDocker Compose¿ÉÒÔÇáËɵØÔÚÉú²úÇéÐÎÖа²ÅźÍÖÎÀíÈÝÆ÷¡£Ï£Íû±¾ÎĶÔÄúÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃDockerÈÝÆ÷ÔÚLinuxÉϾÙÐÐÒ»Á¬¼¯³ÉºÍÒ»Á¬°²ÅÅ£¿µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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