Docker×÷ΪÐÂÒ»´úµÄÐéÄ⻯·½Ê½£¬Î´À´¿Ï¶¨»áµÃµ½¹ã·ºµÄÓ¦Ó㬴«Í³ÐéÄâ»úµÄ²¿Êð·½Ê½Òª±£Ö¤¿ª·¢»·¾³¡¢²âÊÔ»·¾³¡¢UAT»·¾³¡¢Éú²ú»·¾³µÄÒÀÀµÒ»ÖÂÐÔ£¬ÐèÒª´óÁ¿µÄÔËάÈËÁ¦£¬Ê¹ÓÃDockerÎÒÃÇ¿ÉÒÔʵÏÖÒ»´Î²¿Ê𣬵½´¦ÔËÐС£
±¾ÎĽéÉÜÈçºÎ°ÑASP.NET CoreÍøÕ¾²¿ÊðÔÚDockerÖÐÔËÐС£
Èí¼þ»·¾³Çåµ¥CentOS 7.3.1611
Docker 1.12.6
.NET Core 1.1
$ #°²×°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 [ÈÝÆ÷Ãû³Æ] ɾ³ýÈÝÆ÷»ò»»¸öÃû³Æ¡£
¡¡