HTML5¼¼Êõ

ASP.NET Core ÍøÕ¾ÔÚDockerÖÐÔËÐÐ - Âþ²½³¤½­

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-04-13 12:00 ÎÒÒªÆÀÂÛ( )

Docker×÷ΪÐÂÒ»´úµÄÐéÄ⻯·½Ê½£¬Î´À´¿Ï¶¨»áµÃµ½¹ã·ºµÄÓ¦Ó㬴«Í³ÐéÄâ»úµÄ²¿Êð·½Ê½Òª±£Ö¤¿ª·¢»·¾³¡¢²âÊÔ»·¾³¡¢UAT»·¾³¡¢Éú²ú»·¾³µÄÒÀÀµÒ»ÖÂÐÔ£¬ÐèÒª´óÁ¿µÄÔËάÈËÁ¦£¬Ê¹ÓÃDockerÎÒÃÇ¿ÉÒÔʵÏÖÒ»´Î²¿Ê𣬵½´¦ÔËÐС£ ±¾ÎĽéÉÜÈçºÎ°ÑASP.NET CoreÍøÕ¾²¿ÊðÔÚDocker

Docker×÷ΪÐÂÒ»´úµÄÐéÄ⻯·½Ê½£¬Î´À´¿Ï¶¨»áµÃµ½¹ã·ºµÄÓ¦Ó㬴«Í³ÐéÄâ»úµÄ²¿Êð·½Ê½Òª±£Ö¤¿ª·¢»·¾³¡¢²âÊÔ»·¾³¡¢UAT»·¾³¡¢Éú²ú»·¾³µÄÒÀÀµÒ»ÖÂÐÔ£¬ÐèÒª´óÁ¿µÄÔËάÈËÁ¦£¬Ê¹ÓÃDockerÎÒÃÇ¿ÉÒÔʵÏÖÒ»´Î²¿Ê𣬵½´¦ÔËÐС£

±¾ÎĽéÉÜÈçºÎ°ÑASP.NET CoreÍøÕ¾²¿ÊðÔÚDockerÖÐÔËÐС£

Èí¼þ»·¾³Çåµ¥

CentOS 7.3.1611
Docker 1.12.6
.NET Core 1.1

°²×°Docker

$ #°²×°Docker $ yum install docker $ #Æô¶¯docker·þÎñ $ systemctl start docker.service $ #ÅäÖÿª»úÆô¶¯ $ systemctl enable docker.service

ÅäÖÃDocker¼ÓËÙÆ÷

ÓÉÓÚÖÚËùÖÜÖªµÄÔ­Òò£¬ÒªÏëÁ÷³©µØʹÓÃDocker£¬ÐèÒªÅäÖÃDocker¼ÓËÙÆ÷£¬·ñÔòÄã»á¾õµÃ»Øµ½Á˲¦ºÅÉÏÍøµÄʱ´ú¡£
ÎÒʹÓõÄÊÇDaoCloud£¬ºÅ³ÆÓÀ¾ÃÃâ·Ñ¡£×¢²áµØÖ·ÊÇ£ºhttps://account.daocloud.io/signin¡£


ÓÃ΢ÐÅɨһɨ¾Í¿ÉÒÔ¿ìËÙÍê³É×¢²á¡£
×¢²áÍê³É»áÌṩÓÐÒ»¸öÅäÖýű¾µØÖ·£º

$ #ÅäÖÃdocker¼ÓËÙÆ÷ $ curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s $ #ÖØÆôÉúЧ $ systemctl restart docker

À­È¡ASP.NET Core¾µÏñ

$ docker pull microsoft/aspnetcore $ #¼ì²éÊÇ·ñ³É¹¦ $ docker images

×¼±¸ASP.NET CoreÍøÕ¾·¢²¼Îļþ

¿ÉÒԲο¼ÎÒ֮ǰµÄÎÄÕ£ºASP.NET Core ÍøÕ¾·¢²¼µ½Linux·þÎñÆ÷

´´½¨Dockerfile

·Åµ½ÍøÕ¾¸ùĿ¼£¬ÎļþÄÚÈݲο¼ÈçÏ£º

FROM docker.io/microsoft/aspnetcore COPY ./publish WORKDIR /publish

´ò°ü¾µÏñ

$ #×¢Òâ×îºóÓиöµã¡£ $ docker build -t test-netcore:1.0 .

Æô¶¯ÈÝÆ÷

$ docker run --name test-netcore -p 8080:8080 -d test-netcore:1.0 $ #¼ì²éÈÝÆ÷ÊÇ·ñÆô¶¯³É¹¦ $ docker ps


ÍøÕ¾ÔËÐгɹ¦¡£

¸½

ÅäÖùý³ÌÎÒÓöµ½ÈÝÆ÷Æô¶¯Ê§°ÜµÄÁ½¸öÇé¿ö£º
1.ÍøÕ¾µÄ¼àÌýʹÓÃÁËip£¬±¨´í¡°Error -99 EADDRNOTAVAIL address not available¡±
2.ÍøÕ¾µÄ¼àÌýʹÓÃÁËlocalhost£¬±¨´í¡°curl: (56) Recv failure: Connection reset by peer¡±
×îºó·¢ÏÖʹÓÃhttp:*:8080À´¼àÌý²Å³É¹¦¡£

docker run ʧ°ÜºóÔÙ´ÎÔËÐлáÌáʾÃû³ÆÒÑ´æÔÚ£¬¿ÉÒÔʹÓÃdocker rm -f [ÈÝÆ÷Ãû³Æ] ɾ³ýÈÝÆ÷»ò»»¸öÃû³Æ¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • .NetCoreÉÏ´«¶àÎļþµÄ¼¸ÖÖʾÀý - ÉñÅ£²½ÐÐ3

    .NetCoreÉÏ´«¶àÎļþµÄ¼¸ÖÖʾÀý - ÉñÅ£²½ÐÐ3

    2017-04-11 18:00

  • ÔƼÆËã֮·-°¢ÀïÔÆÉÏ£ºÊý¾Ý¿âÁ¬½ÓÊý¹ýÍòµÄÕæÏ࣬´Ó°¢ÀïÔÆRDSµ½Î¢Èí.NET Core - ²©¿ÍÔ°ÍŶÓ

    ÔƼÆËã֮·-°¢ÀïÔÆÉÏ£ºÊý¾Ý¿âÁ¬½ÓÊý¹ýÍòµÄÕæÏ࣬´Ó°¢ÀïÔÆRDSµ½Î¢Èí.N

    2017-04-08 15:00

  • VS 2017¿ª·¢ASP.NET Core WebÓ¦Óùý³ÌÖз¢ÏÖµÄÒ»¸öÖØ´óBug - ë…ö­ö­

    VS 2017¿ª·¢ASP.NET Core WebÓ¦Óùý³ÌÖз¢ÏÖµÄÒ»¸öÖØ´óBug - ë…ö­ö­

    2017-04-07 16:01

  • ÔÚIISÉϲ¿ÊðÄãµÄASP.NET CoreÏîÄ¿ - Íõ½Ü¹â

    ÔÚIISÉϲ¿ÊðÄãµÄASP.NET CoreÏîÄ¿ - Íõ½Ü¹â

    2017-04-07 08:00

ÍøÓѵãÆÀ
»