尊龙凯时人生就是博

ÔõôÐÞ¸ÄdockerÖÐÈÝÆ÷Ó³ÉäµÄ¶Ë¿Ú

ÐÞ¸Ä docker ÈÝÆ÷Ó³ÉäµÄ¶Ë¿ÚµÄÒªÁìÓУºÊ¹Óà –publish »ò -p ±ê¼ÇÖØÐÂÆô¶¯ÈÝÆ÷£¬Ö¸¶¨ÐµÄÓ³Éä¶Ë¿Ú¡£Ê¹Óà docker compose ÐÞ¸Ä docker-compose.yml ÎļþÖÐµÄ ports ²¿·Ö¡£Í¨¹ý docker engine api ʹÓà curl ÏÂÁîÐ޸Ķ˿ÚÓ³Éä¡£

ÔõÑùÐÞ¸Ä Docker ÈÝÆ÷Ó³ÉäµÄ¶Ë¿Ú

Docker ÈÝÆ÷Ó³Éä¶Ë¿ÚÊǽ«ÈÝÆ÷ÄÚ²¿¶Ë¿ÚÓëÖ÷»ú¶Ë¿Ú¹ØÁªµÄ»úÖÆ¡£ÒªÐÞ¸ÄÈÝÆ÷Ó³ÉäµÄ¶Ë¿Ú£¬¿ÉÒÔ½ÓÄÉÒÔÏ°취£º

1. È·¶¨ÒªÐ޸ĵĶ˿ÚÓ³Éä

Ê×ÏÈ£¬È·¶¨ÒªÐ޸ĵÄÈÝÆ÷ÓëÆäÓ³ÉäµÄÖ÷»ú¶Ë¿Ú¡ £¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

docker ps -a

µÇ¼ºó¸´ÖÆ

Õ⽫ÁгöËùÓÐÕýÔÚÔËÐкÍÒÑ×èÖ¹µÄÈÝÆ÷¡£ÕÒµ½ÒªÐ޸ĵÄÈÝÆ÷²¢Éó²é “PORTS” ÁÐÒÔ»ñÈ¡Ä¿½ñ¶Ë¿ÚÓ³Éä¡£

2. ÖØÆôÈÝÆ÷²¢Ö¸¶¨ÐµĶ˿ÚÓ³Éä

ʹÓà –publish »ò -p ±ê¼ÇÖØÐÂÆô¶¯ÈÝÆ÷£¬ºó¸úÒªÓ³ÉäµÄж˿Ú¡£ÀýÈ磺

docker run -it --rm --name my-app -p 8081:80 my-app-image

µÇ¼ºó¸´ÖÆ

´ËÏÂÁÖØÐÂÆô¶¯ÃûΪ “my-app” µÄÈÝÆ÷£¬²¢½«ÆäÄÚ²¿¶Ë¿Ú 80 Ó³Éäµ½Ö÷»ú¶Ë¿Ú 8081¡£

3. ʹÓà docker-compose Ð޸Ķ˿ÚÓ³Éä

ÈôÊÇʹÓõÄÊÇ Docker Compose£¬¿ÉÒÔÔÚ docker-compose.yml ÎļþÖÐÐ޸Ķ˿ÚÓ³Éä¡£ÕÒµ½ÒªÐÞ¸ÄÈÝÆ÷µÄ ports ²¿·Ö£¬È»ºóÖ¸¶¨ÐµÄÖ÷»ú¶Ë¿Ú¡£ÀýÈ磺

services:
  my-app:
    image: my-app-image
    ports:
      - "8081:80"

µÇ¼ºó¸´ÖÆ

4. ʹÓà Docker Engine API

»¹¿ÉÒÔͨ¹ý Docker Engine API Ð޸Ķ˿ÚÓ³Éä¡ £¿ÉÒÔʹÓÃÒÔÏ cURL ÏÂÁ

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"ExposedPorts": {"80/tcp": {}}}' \
  -H "Authorization: Bearer <access_token>" \
  https://<docker_host>/containers/<container_id>/update</container_id></docker_host></access_token>

µÇ¼ºó¸´ÖÆ

Çë×¢ÖØ£¬ ÐèÒªÌ滻Ϊ Docker ÊØ»¤Àú³ÌµÄ»á¼ûÁîÅÆ£¬¶ø ÐèÒªÌ滻ΪҪÐ޸ĵÄÈÝÆ÷ ID¡£

ÒÔÉϾÍÊÇÔõôÐÞ¸ÄdockerÖÐÈÝÆ÷Ó³ÉäµÄ¶Ë¿ÚµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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