{"id":35045,"date":"2024-10-22T11:14:04","date_gmt":"2024-10-22T04:14:04","guid":{"rendered":"http:\/\/jupitek.maudemo.vip\/index.php\/2024\/10\/22\/how-to-deploy-microservices-with-docker\/"},"modified":"2024-10-22T11:14:04","modified_gmt":"2024-10-22T04:14:04","slug":"how-to-deploy-microservices-with-docker","status":"publish","type":"post","link":"https:\/\/jupitek.maudemo.vip\/index.php\/2024\/10\/22\/how-to-deploy-microservices-with-docker\/","title":{"rendered":"Tri\u1ec3n khai Microservices v\u1edbi Docker"},"content":{"rendered":"<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/how-to-deploy-microservices-with-docker-smg_hu4000e2fd68369bd29c06bea9e3804b2e_39194_1388x0_resize_q71_bgfafafc_catmullrom.jpg\" alt=\"Tri\u1ec3n khai Microservices v\u1edbi Docker\" title=\"Tri\u1ec3n khai Microservices v\u1edbi Docker\"\/><\/figure>\n<h2 id=\"what-is-a-microservice\">Microservice l\u00e0 g\u00ec?<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#what-is-a-microservice\"><\/a><\/h2>\n<p>Microservices l\u00e0 m\u1ed9t ki\u1ebfn \u200b\u200btr\u00fac ng\u00e0y c\u00e0ng ph\u1ed5 bi\u1ebfn \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng quy m\u00f4 l\u1edbn. Thay v\u00ec s\u1eed d\u1ee5ng m\u1ed9t c\u01a1 s\u1edf m\u00e3 \u0111\u01a1n kh\u1ed1i, c\u00e1c \u1ee9ng d\u1ee5ng \u0111\u01b0\u1ee3c chia th\u00e0nh m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c th\u00e0nh ph\u1ea7n nh\u1ecf h\u01a1n \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 microservices. C\u00e1ch ti\u1ebfp c\u1eadn n\u00e0y mang l\u1ea1i m\u1ed9t s\u1ed1 l\u1ee3i \u00edch, bao g\u1ed3m kh\u1ea3 n\u0103ng m\u1edf r\u1ed9ng c\u00e1c microservices ri\u00eang l\u1ebb, gi\u00fap c\u01a1 s\u1edf m\u00e3 d\u1ec5 hi\u1ec3u v\u00e0 d\u1ec5 ki\u1ec3m tra h\u01a1n, v\u00e0 cho ph\u00e9p s\u1eed d\u1ee5ng c\u00e1c ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh, c\u01a1 s\u1edf d\u1eef li\u1ec7u v\u00e0 c\u00e1c c\u00f4ng c\u1ee5 kh\u00e1c nhau cho m\u1ed7i microservices.<\/p>\n<p><a href=\"https:\/\/www.docker.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Docker<\/a>&nbsp;l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 tuy\u1ec7t v\u1eddi \u0111\u1ec3 qu\u1ea3n l\u00fd v\u00e0 tri\u1ec3n khai c\u00e1c d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf. M\u1ed7i d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c chia nh\u1ecf h\u01a1n n\u1eefa th\u00e0nh c\u00e1c quy tr\u00ecnh ch\u1ea1y trong c\u00e1c v\u00f9ng ch\u1ee9a Docker ri\u00eang bi\u1ec7t, c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh b\u1eb1ng Dockerfiles v\u00e0 c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh Docker Compose. K\u1ebft h\u1ee3p v\u1edbi m\u1ed9t c\u00f4ng c\u1ee5 cung c\u1ea5p nh\u01b0 Kubernetes, m\u1ed7i d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf sau \u0111\u00f3 c\u00f3 th\u1ec3 d\u1ec5 d\u00e0ng \u0111\u01b0\u1ee3c tri\u1ec3n khai, m\u1edf r\u1ed9ng v\u00e0 c\u1ed9ng t\u00e1c b\u1edfi m\u1ed9t nh\u00f3m nh\u00e0 ph\u00e1t tri\u1ec3n. Vi\u1ec7c ch\u1ec9 \u0111\u1ecbnh m\u1ed9t m\u00f4i tr\u01b0\u1eddng theo c\u00e1ch n\u00e0y c\u0169ng gi\u00fap d\u1ec5 d\u00e0ng li\u00ean k\u1ebft c\u00e1c d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf v\u1edbi nhau \u0111\u1ec3 t\u1ea1o th\u00e0nh m\u1ed9t \u1ee9ng d\u1ee5ng l\u1edbn h\u01a1n.<\/p>\n<p>H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1ebd ch\u1ec9 cho b\u1ea1n c\u00e1ch x\u00e2y d\u1ef1ng v\u00e0 tri\u1ec3n khai m\u1ed9t d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf m\u1eabu b\u1eb1ng Docker v\u00e0 Docker Compose.<\/p>\n<h2 id=\"before-you-begin\">Tr\u01b0\u1edbc khi b\u1ea1n b\u1eaft \u0111\u1ea7u<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#before-you-begin\"><\/a><\/h2>\n<ol>\n<li>N\u1ebfu b\u1ea1n ch\u01b0a th\u1ef1c hi\u1ec7n, h\u00e3y t\u1ea1o m\u1ed9t t\u00e0i kho\u1ea3n Linode v\u00e0 Compute Instance. Xem h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/platform\/get-started\/\">B\u1eaft \u0111\u1ea7u v\u1edbi Linode<\/a>&nbsp;v\u00e0&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/create\/\">T\u1ea1o Compute Instance<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i .<\/li>\n<li>L\u00e0m theo h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/products\/compute\/compute-instances\/guides\/set-up-and-secure\/\">Thi\u1ebft l\u1eadp v\u00e0 B\u1ea3o m\u1eadt Phi\u00ean b\u1ea3n Compute<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i \u0111\u1ec3 c\u1eadp nh\u1eadt h\u1ec7 th\u1ed1ng c\u1ee7a b\u1ea1n. B\u1ea1n c\u0169ng c\u00f3 th\u1ec3 mu\u1ed1n \u0111\u1eb7t m\u00fai gi\u1edd, c\u1ea5u h\u00ecnh t\u00ean m\u00e1y ch\u1ee7, t\u1ea1o t\u00e0i kho\u1ea3n ng\u01b0\u1eddi d\u00f9ng gi\u1edbi h\u1ea1n v\u00e0 t\u0103ng c\u01b0\u1eddng quy\u1ec1n truy c\u1eadp SSH.<\/li>\n<\/ol>\n<p class=\"has-background\" style=\"background-color:#74f78c33\">Ghi ch\u00fa: H\u01b0\u1edbng d\u1eabn n\u00e0y \u0111\u01b0\u1ee3c vi\u1ebft cho ng\u01b0\u1eddi d\u00f9ng kh\u00f4ng ph\u1ea3i root. C\u00e1c l\u1ec7nh y\u00eau c\u1ea7u quy\u1ec1n n\u00e2ng cao \u0111\u01b0\u1ee3c th\u00eam ti\u1ec1n t\u1ed1&nbsp;<code>sudo<\/code>. N\u1ebfu b\u1ea1n kh\u00f4ng quen v\u1edbi&nbsp;<code>sudo<\/code>l\u1ec7nh n\u00e0y, b\u1ea1n c\u00f3 th\u1ec3 xem h\u01b0\u1edbng d\u1eabn&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/linux-users-and-groups\/\">Ng\u01b0\u1eddi d\u00f9ng v\u00e0 Nh\u00f3m<\/a>&nbsp;c\u1ee7a ch\u00fang t\u00f4i .<\/p>\n<h3 id=\"install-docker\">C\u00e0i \u0111\u1eb7t Docker<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#install-docker\"><\/a><\/h3>\n<p>\u0110\u1ec3 c\u00e0i \u0111\u1eb7t Docker CE (Phi\u00ean b\u1ea3n c\u1ed9ng \u0111\u1ed3ng), h\u00e3y l\u00e0m theo h\u01b0\u1edbng d\u1eabn trong m\u1ed9t trong c\u00e1c h\u01b0\u1edbng d\u1eabn d\u01b0\u1edbi \u0111\u00e2y:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.linode.com\/docs\/guides\/installing-and-using-docker-on-ubuntu-and-debian\/\">C\u00e0i \u0111\u1eb7t v\u00e0 s\u1eed d\u1ee5ng Docker tr\u00ean Ubuntu v\u00e0 Debian<\/a><\/li>\n<li><a href=\"https:\/\/www.linode.com\/docs\/guides\/installing-and-using-docker-on-centos-and-fedora\/\">C\u00e0i \u0111\u1eb7t v\u00e0 s\u1eed d\u1ee5ng Docker tr\u00ean CentOS v\u00e0 Fedora<\/a><\/li>\n<\/ul>\n<p>\u0110\u1ec3 xem h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t cho c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i Linux ho\u1eb7c h\u1ec7 \u0111i\u1ec1u h\u00e0nh kh\u00e1c nh\u01b0 Mac ho\u1eb7c Windows, h\u00e3y tham kh\u1ea3o t\u00e0i li\u1ec7u ch\u00ednh th\u1ee9c c\u1ee7a Docker t\u1ea1i \u0111\u00e2y:&nbsp;<a href=\"https:\/\/docs.docker.com\/engine\/install\/\" target=\"_blank\" rel=\"noreferrer noopener\">C\u00e0i \u0111\u1eb7t Docker Engine<\/a><\/p>\n<h3 id=\"install-docker-compose\">C\u00e0i \u0111\u1eb7t Docker Compose<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#install-docker-compose\"><\/a><\/h3>\n<p>Docker Compose c\u00f3 s\u1eb5n trong c\u00e1c bi\u1ebfn th\u1ec3 plugin v\u00e0 \u0111\u1ed9c l\u1eadp. Tuy nhi\u00ean, t\u00e0i li\u1ec7u ch\u00ednh th\u1ee9c c\u1ee7a Docker \u01b0u ti\u00ean plugin. H\u01a1n n\u1eefa, plugin c\u00f3 c\u00e0i \u0111\u1eb7t \u0111\u01a1n gi\u1ea3n v\u00e0 ho\u1ea1t \u0111\u1ed9ng t\u1ed1t v\u1edbi c\u00e1c l\u1ec7nh Docker Compose tr\u01b0\u1edbc \u0111\u00e2y.<\/p>\n<p>C\u00e1c b\u01b0\u1edbc n\u00e0y cho th\u1ea5y c\u00e1ch c\u00e0i \u0111\u1eb7t plugin Docker Compose. N\u1ebfu b\u1ea1n quan t\u00e2m \u0111\u1ebfn vi\u1ec7c c\u00e0i \u0111\u1eb7t \u1ee9ng d\u1ee5ng Docker Compose \u0111\u1ed9c \u200b\u200bl\u1eadp, h\u00e3y l\u00e0m theo&nbsp;<a href=\"https:\/\/docs.docker.com\/compose\/install\/other\/#on-linux\" target=\"_blank\" rel=\"noreferrer noopener\">h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t ch\u00ednh th\u1ee9c<\/a>&nbsp;c\u1ee7a Docker .<\/p>\n<p>Ghi ch\u00fa<\/p>\n<p>Nhi\u1ec1u h\u01b0\u1edbng d\u1eabn v\u1eabn gi\u1eef nguy\u00ean \u0111\u1ecbnh d\u1ea1ng l\u1ec7nh \u0111\u1ed9c l\u1eadp Docker Compose, tr\u00f4ng nh\u01b0 sau:<\/p>\n<pre class=\"wp-block-code\"><code>docker-compose <strong>&#91;<\/strong>command<strong>]<\/strong><\/code><\/pre>\n<p>H\u00e3y \u0111\u1ea3m b\u1ea3o thay th\u1ebf l\u1ec7nh n\u00e0y b\u1eb1ng \u0111\u1ecbnh d\u1ea1ng l\u1ec7nh c\u1ee7a plugin khi s\u1eed d\u1ee5ng ph\u01b0\u01a1ng ph\u00e1p c\u00e0i \u0111\u1eb7t n\u00e0y. \u0110i\u1ec1u n\u00e0y th\u01b0\u1eddng ch\u1ec9 c\u00f3 ngh\u0129a l\u00e0 thay th\u1ebf d\u1ea5u g\u1ea1ch n\u1ed1i b\u1eb1ng m\u1ed9t kho\u1ea3ng tr\u1eafng, nh\u01b0 trong:<\/p>\n<pre class=\"wp-block-code\"><code>docker compose <strong>&#91;<\/strong>command<strong>]<\/strong><\/code><\/pre>\n<p>1.B\u1eadt kho l\u01b0u tr\u1eef Docker cho tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i c\u1ee7a h\u1ec7 th\u1ed1ng. Kho l\u01b0u tr\u1eef th\u01b0\u1eddng \u0111\u00e3 \u0111\u01b0\u1ee3c b\u1eadt sau khi b\u1ea1n c\u00e0i \u0111\u1eb7t c\u00f4ng c\u1ee5 Docker. H\u00e3y l\u00e0m theo h\u01b0\u1edbng d\u1eabn li\u00ean quan c\u1ee7a ch\u00fang t\u00f4i v\u1ec1 c\u00e1ch c\u00e0i \u0111\u1eb7t Docker \u0111\u1ec3 b\u1eadt kho l\u01b0u tr\u1eef tr\u00ean h\u1ec7 th\u1ed1ng c\u1ee7a b\u1ea1n.<\/p>\n<p>2.C\u1eadp nh\u1eadt tr\u00ecnh qu\u1ea3n l\u00fd g\u00f3i c\u1ee7a b\u1ea1n v\u00e0 c\u00e0i \u0111\u1eb7t plugin Docker Compose.<\/p>\n<p>Tr\u00ean h\u1ec7 th\u1ed1ng&nbsp;<strong>Debian<\/strong>&nbsp;v\u00e0&nbsp;<strong>Ubuntu<\/strong>&nbsp;, h\u00e3y s\u1eed d\u1ee5ng c\u00e1c l\u1ec7nh sau:<\/p>\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install docker-compose-plugin<\/code><\/pre>\n<p>Tr\u00ean&nbsp;<strong>CentOS<\/strong>&nbsp;,&nbsp;<strong>Fedora<\/strong>&nbsp;v\u00e0 c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i d\u1ef1a tr\u00ean RPM kh\u00e1c, h\u00e3y s\u1eed d\u1ee5ng c\u00e1c l\u1ec7nh sau:<\/p>\n<pre class=\"wp-block-code\"><code>sudo yum update\nsudo yum install docker-compose-plugin<\/code><\/pre>\n<h2 id=\"prepare-the-environment\">Chu\u1ea9n b\u1ecb m\u00f4i tr\u01b0\u1eddng<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#prepare-the-environment\"><\/a><\/h2>\n<p>Ph\u1ea7n n\u00e0y s\u1eed d\u1ee5ng Dockerfiles \u0111\u1ec3 c\u1ea5u h\u00ecnh Docker image. \u0110\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 c\u00fa ph\u00e1p Dockerfile v\u00e0 c\u00e1c ph\u01b0\u01a1ng ph\u00e1p hay nh\u1ea5t, h\u00e3y xem&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/how-to-use-dockerfiles\/\">h\u01b0\u1edbng d\u1eabn C\u00e1ch s\u1eed d\u1ee5ng Dockerfiles<\/a>&nbsp;v\u00e0&nbsp;<a href=\"https:\/\/docs.docker.com\/engine\/userguide\/eng-image\/dockerfile_best-practices\/#sort-multi-line-arguments\" target=\"_blank\" rel=\"noreferrer noopener\">h\u01b0\u1edbng d\u1eabn Th\u1ef1c h\u00e0nh t\u1ed1t nh\u1ea5t c\u1ee7a Dockerfile<\/a>&nbsp;c\u1ee7a Docker .<\/p>\n<p>1.T\u1ea1o th\u01b0 m\u1ee5c cho d\u1ecbch v\u1ee5 vi m\u00f4:<\/p>\n<pre class=\"wp-block-code\"><code>mkdir flask-microservice\n<\/code><\/pre>\n<p>2.T\u1ea1o c\u1ea5u tr\u00fac th\u01b0 m\u1ee5c cho c\u00e1c th\u00e0nh ph\u1ea7n d\u1ecbch v\u1ee5 vi m\u00f4 trong th\u01b0 m\u1ee5c m\u1edbi:<\/p>\n<pre class=\"wp-block-code\"><code>cd flask-microservice\nmkdir nginx postgres web<\/code><\/pre>\n<h3 id=\"nginx\">NGINX<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#nginx\"><\/a><\/h3>\n<p>1.Trong th\u01b0 m\u1ee5c con m\u1edbi&nbsp;<code>nginx<\/code>, h\u00e3y t\u1ea1o Dockerfile cho h\u00ecnh \u1ea3nh NGINX:<\/p>\n<pre class=\"wp-block-code\"><code>from nginx:alpine\nCOPY nginx.conf \/etc\/nginx\/nginx.conf<\/code><\/pre>\n<p>2.T\u1ea1o&nbsp;<code>nginx.conf<\/code>tham chi\u1ebfu trong Dockerfile:<\/p>\n<pre class=\"wp-block-code\"><code>user  nginx;\nworker_processes 1;\nerror_log  \/dev\/stdout info;\nerror_log off;\npid        \/var\/run\/nginx.pid;\n\nevents {\n    worker_connections  1024;\n    use epoll;\n    multi_accept on;\n}\n\nhttp {\n    include       \/etc\/nginx\/mime.types;\n    default_type  application\/octet-stream;\n\n    log_format  main  '$remote_addr - $remote_user &#91;$time_local] \"$request\" '\n                      '$status $body_bytes_sent \"$http_referer\" '\n                      '\"$http_user_agent\" \"$http_x_forwarded_for\"';\n\n    access_log  \/dev\/stdout main;\n    access_log off;\n    keepalive_timeout 65;\n    keepalive_requests 100000;\n    tcp_nopush on;\n    tcp_nodelay on;\n\n    server {\n        listen 80;\n        proxy_pass_header Server;\n\n        location \/ {\n            proxy_set_header Host $host;\n            proxy_set_header X-Real-IP $remote_addr;\n\n            # app comes from \/etc\/hosts, Docker added it for us!\n            proxy_pass http:\/\/flaskapp:8000\/;\n        }\n    }\n}<\/code><\/pre>\n<h3 id=\"postgresql\">PostgreSQL<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#postgresql\"><\/a><\/h3>\n<p>\u1ea2nh PostgreSQL cho d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf n\u00e0y s\u1ebd s\u1eed d\u1ee5ng&nbsp;<code>postgresql<\/code>\u1ea3nh ch\u00ednh th\u1ee9c tr\u00ean Docker Hub, do \u0111\u00f3 kh\u00f4ng c\u1ea7n Dockerfile.<\/p>\n<p>Trong&nbsp;<code>postgres<\/code>th\u01b0 m\u1ee5c con, t\u1ea1o m\u1ed9t&nbsp;<code>init.sql<\/code>t\u1ec7p:<\/p>\n<pre class=\"wp-block-code\"><code>SET statement_timeout = 0;\nSET lock_timeout = 0;\nSET idle_in_transaction_session_timeout = 0;\nSET client_encoding = 'UTF8';\nSET standard_conforming_strings = on;\nSET check_function_bodies = false;\nSET client_min_messages = warning;\nSET row_security = off;\nCREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;\nCOMMENT ON EXTENSION plpgsql IS 'PL\/pgSQL procedural language';\nSET search_path = public, pg_catalog;\nSET default_tablespace = '';\nSET default_with_oids = false;\nCREATE TABLE visitors (\n    site_id integer,\n    site_name text,\n    visitor_count integer\n);\n\nALTER TABLE visitors OWNER TO postgres;\nCOPY visitors (site_id, site_name, visitor_count) FROM stdin;\n1 \tlinodeexample.com  \t0\n\\.<\/code><\/pre>\n<p class=\"has-background\" style=\"background-color:#f32a2a33\">Quan tr\u1ecdng: \u1ede D\u00f2ng 22 c\u1ee7a&nbsp;<code>init.sql<\/code>, h\u00e3y \u0111\u1ea3m b\u1ea3o tr\u00ecnh so\u1ea1n th\u1ea3o v\u0103n b\u1ea3n c\u1ee7a b\u1ea1n kh\u00f4ng chuy\u1ec3n \u0111\u1ed5i tab th\u00e0nh kho\u1ea3ng tr\u1eafng. \u1ee8ng d\u1ee5ng s\u1ebd kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng n\u1ebfu kh\u00f4ng c\u00f3 tab gi\u1eefa c\u00e1c m\u1ee5c trong d\u00f2ng n\u00e0y.<\/p>\n<h3 id=\"web\">Trang web<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#web\"><\/a><\/h3>\n<p>H\u00ecnh&nbsp;<code>web<\/code>\u1ea3nh s\u1ebd ch\u1ee9a m\u1ed9t \u1ee9ng d\u1ee5ng Flask m\u1eabu. Th\u00eam c\u00e1c t\u1ec7p sau v\u00e0o&nbsp;<code>web<\/code>th\u01b0 m\u1ee5c \u0111\u1ec3 chu\u1ea9n b\u1ecb \u1ee9ng d\u1ee5ng:<\/p>\n<p>1.T\u1ea1o m\u1ed9t&nbsp;<code>.python-version<\/code>t\u1ec7p \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh vi\u1ec7c s\u1eed d\u1ee5ng Python 3.6:<\/p>\n<pre class=\"wp-block-code\"><code>echo \"3.6.0\" &gt;&gt; web\/.python-version\n<\/code><\/pre>\n<p>2.T\u1ea1o Dockerfile cho&nbsp;<code>web<\/code>h\u00ecnh \u1ea3nh:<\/p>\n<pre class=\"wp-block-code\"><code>from python:3.6.2-slim\nRUN groupadd flaskgroup &amp;&amp; useradd -m -g flaskgroup -s \/bin\/bash flask\nRUN echo \"flask ALL=(ALL) NOPASSWD:ALL\" &gt;&gt; \/etc\/sudoers\nRUN mkdir -p \/home\/flask\/app\/web\nWORKDIR \/home\/flask\/app\/web\nCOPY requirements.txt \/home\/flask\/app\/web\nRUN pip install --no-cache-dir -r requirements.txt\nRUN chown -R flask:flaskgroup \/home\/flask\nUSER flask\nENTRYPOINT &#91;\"\/usr\/local\/bin\/gunicorn\", \"--bind\", \":8000\", \"linode:app\", \"--reload\", \"--workers\", \"16\"]<\/code><\/pre>\n<p>3.T\u1ea1o&nbsp;<code>web\/linode.py<\/code>v\u00e0 th\u00eam t\u1eadp l\u1ec7nh \u1ee9ng d\u1ee5ng m\u1eabu:<\/p>\n<pre class=\"wp-block-code\"><code>from flask import Flask\nimport logging\nimport psycopg2\nimport redis\nimport sys\n\napp = Flask(__name__)\ncache = redis.StrictRedis(host='redis', port=6379)\n\n# Configure Logging\napp.logger.addHandler(logging.StreamHandler(sys.stdout))\napp.logger.setLevel(logging.DEBUG)\n\ndef PgFetch(query, method):\n\n    # Connect to an existing database\n    conn = psycopg2.connect(\"host='postgres' dbname='linode' user='postgres' password='linode123'\")\n\n    # Open a cursor to perform database operations\n    cur = conn.cursor()\n\n    # Query the database and obtain data as Python objects\n    dbquery = cur.execute(query)\n\n    if method == 'GET':\n        result = cur.fetchone()\n    else:\n        result = \"\"\n\n    # Make the changes to the database persistent\n    conn.commit()\n\n    # Close communication with the database\n    cur.close()\n    conn.close()\n    return result\n\n@app.route('\/')\ndef hello_world():\n    if cache.exists('visitor_count'):\n        cache.incr('visitor_count')\n        count = (cache.get('visitor_count')).decode('utf-8')\n        update = PgFetch(\"UPDATE visitors set visitor_count = \" + count + \" where site_id = 1;\", \"POST\")\n    else:\n        cache_refresh = PgFetch(\"SELECT visitor_count FROM visitors where site_id = 1;\", \"GET\")\n        count = int(cache_refresh&#91;0])\n        cache.set('visitor_count', count)\n        cache.incr('visitor_count')\n        count = (cache.get('visitor_count')).decode('utf-8')\n    return 'Hello Linode!  This page has been viewed %s time(s).' % count\n\n@app.route('\/resetcounter')\ndef resetcounter():\n    cache.delete('visitor_count')\n    PgFetch(\"UPDATE visitors set visitor_count = 0 where site_id = 1;\", \"POST\")\n    app.logger.debug(\"reset visitor count\")\n    return \"Successfully deleted redis and postgres counters\"<\/code><\/pre>\n<p>4.Th\u00eam m\u1ed9t&nbsp;<code>requirements.txt<\/code>t\u1ec7p c\u00f3 c\u00e1c ph\u1ee5 thu\u1ed9c Python c\u1ea7n thi\u1ebft:<\/p>\n<pre class=\"wp-block-code\"><code>flask\ngunicorn\npsycopg2-binary\nredis<\/code><\/pre>\n<h2 id=\"docker-compose\">Docker So\u1ea1n th\u1ea3o<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#docker-compose\"><\/a><\/h2>\n<p>Docker Compose s\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh k\u1ebft n\u1ed1i gi\u1eefa c\u00e1c container v\u00e0 c\u00e0i \u0111\u1eb7t c\u1ea5u h\u00ecnh c\u1ee7a ch\u00fang.<\/p>\n<p>T\u1ea1o m\u1ed9t&nbsp;<code>docker-compose.yml<\/code>t\u1ec7p trong&nbsp;<code>flask-microservice<\/code>th\u01b0 m\u1ee5c v\u00e0 th\u00eam n\u1ed9i dung sau:<\/p>\n<pre class=\"wp-block-code\"><code>version: '3'\nservices:\n # Define the Flask web application\n flaskapp:\n\n   # Build the Dockerfile that is in the web directory\n   build: .\/web\n\n   # Always restart the container regardless of the exit status; try and restart the container indefinitely\n   restart: always\n\n   # Expose port 8000 to other containers (not to the host of the machine)\n   expose:\n     - \"8000\"\n\n   # Mount the web directory within the container at \/home\/flask\/app\/web\n   volumes:\n     - .\/web:\/home\/flask\/app\/web\n\n   # Don't create this container until the redis and postgres containers (below) have been created\n   depends_on:\n     - redis\n     - postgres\n\n   # Link the redis and postgres containers together so they can talk to one another\n   links:\n     - redis\n     - postgres\n\n   # Pass environment variables to the flask container (this debug level lets you see more useful information)\n   environment:\n     FLASK_DEBUG: 1\n\n   # Deploy with three replicas in the case one of the containers fails (only in Docker Swarm)\n   deploy:\n     mode: replicated\n     replicas: 3\n\n # Define the redis Docker container\n redis:\n\n   # use the redis:alpine image: https:\/\/hub.docker.com\/_\/redis\/\n   image: redis:alpine\n   restart: always\n   deploy:\n     mode: replicated\n     replicas: 3\n\n # Define the redis NGINX forward proxy container\n nginx:\n\n   # build the nginx Dockerfile: http:\/\/bit.ly\/2kuYaIv\n   build: nginx\/\n   restart: always\n\n   # Expose port 80 to the host machine\n   ports:\n     - \"80:80\"\n   deploy:\n     mode: replicated\n     replicas: 3\n\n   # The Flask application needs to be available for NGINX to make successful proxy requests\n   depends_on:\n     - flaskapp\n\n # Define the postgres database\n postgres:\n   restart: always\n   # Use the postgres alpine image: https:\/\/hub.docker.com\/_\/postgres\/\n   image: postgres:alpine\n\n   # Mount an initialization script and the persistent postgresql data volume\n   volumes:\n     - .\/postgres\/init.sql:\/docker-entrypoint-initdb.d\/init.sql\n     - .\/postgres\/data:\/var\/lib\/postgresql\/data\n\n   # Pass postgres environment variables\n   environment:\n     POSTGRES_PASSWORD: linode123\n     POSTGRES_DB: linode\n\n   # Expose port 5432 to other Docker containers\n   expose:\n     - \"5432\"<\/code><\/pre>\n<h2 id=\"test-the-microservice\">Ki\u1ec3m tra d\u1ecbch v\u1ee5 vi m\u00f4<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#test-the-microservice\"><\/a><\/h2>\n<p>1.S\u1eed d\u1ee5ng Docker Compose \u0111\u1ec3 x\u00e2y d\u1ef1ng t\u1ea5t c\u1ea3 c\u00e1c h\u00ecnh \u1ea3nh v\u00e0 kh\u1edfi \u0111\u1ed9ng d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf:<\/p>\n<pre class=\"wp-block-code\"><code>cd flask-microservice\/ &amp;&amp; docker-compose up\n<\/code><\/pre>\n<p>B\u1ea1n s\u1ebd th\u1ea5y t\u1ea5t c\u1ea3 c\u00e1c d\u1ecbch v\u1ee5 \u0111\u1ec1u kh\u1edfi \u0111\u1ed9ng trong thi\u1ebft b\u1ecb \u0111\u1ea7u cu\u1ed1i c\u1ee7a m\u00ecnh.<\/p>\n<p>2.M\u1edf m\u1ed9t c\u1eeda s\u1ed5 terminal m\u1edbi v\u00e0 g\u1eedi y\u00eau c\u1ea7u t\u1edbi \u1ee9ng d\u1ee5ng v\u00ed d\u1ee5:<\/p>\n<pre class=\"wp-block-code\"><code>curl localhost\/resetcounter<\/code><\/pre>\n<pre class=\"wp-block-code\"><code>Successfully deleted redis and postgres counters<\/code><\/pre>\n<p>4.Quay l\u1ea1i c\u1eeda s\u1ed5 terminal n\u01a1i Docker Compose \u0111\u01b0\u1ee3c kh\u1edfi \u0111\u1ed9ng \u0111\u1ec3 xem nh\u1eadt k\u00fd \u0111\u1ea7u ra chu\u1ea9n:<\/p>\n<pre class=\"wp-block-code\"><code>flaskapp_1  | DEBUG in linode &#91;\/home\/flask\/app\/web\/linode.py:56]:\nflaskapp_1  | reset visitor count<\/code><\/pre>\n<h2 id=\"using-containers-in-production-best-practices\">S\u1eed d\u1ee5ng Container trong s\u1ea3n xu\u1ea5t: Th\u1ef1c h\u00e0nh t\u1ed1t nh\u1ea5t<a href=\"https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/#using-containers-in-production-best-practices\"><\/a><\/h2>\n<p>C\u00e1c container \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong v\u00ed d\u1ee5 v\u1ec1 d\u1ecbch v\u1ee5 vi m\u00f4 nh\u1eb1m m\u1ee5c \u0111\u00edch ch\u1ee9ng minh c\u00e1c bi\u1ec7n ph\u00e1p th\u1ef1c h\u00e0nh t\u1ed1t nh\u1ea5t sau \u0111\u00e2y khi s\u1eed d\u1ee5ng container trong s\u1ea3n xu\u1ea5t:<\/p>\n<p>C\u00e1c th\u00f9ng ch\u1ee9a ph\u1ea3i:<\/p>\n<ol>\n<li><strong>T\u1ea1m th\u1eddi<\/strong>&nbsp;: C\u00f3 th\u1ec3 d\u1ec5 d\u00e0ng d\u1eebng, ph\u00e1 h\u1ee7y, x\u00e2y d\u1ef1ng l\u1ea1i v\u00e0 tri\u1ec3n khai l\u1ea1i container v\u1edbi thi\u1ebft l\u1eadp v\u00e0 c\u1ea5u h\u00ecnh t\u1ed1i thi\u1ec3u.Microservice Flask l\u00e0 m\u1ed9t v\u00ed d\u1ee5 l\u00fd t\u01b0\u1edfng v\u1ec1 \u0111i\u1ec1u n\u00e0y. To\u00e0n b\u1ed9 microservice c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u01b0a l\u00ean ho\u1eb7c h\u1ea1 xu\u1ed1ng b\u1eb1ng Docker Compose. Kh\u00f4ng c\u1ea7n c\u1ea5u h\u00ecnh b\u1ed5 sung n\u00e0o sau khi c\u00e1c container \u0111ang ch\u1ea1y, gi\u00fap d\u1ec5 d\u00e0ng s\u1eeda \u0111\u1ed5i \u1ee9ng d\u1ee5ng.<\/li>\n<li><strong>D\u00f9ng m\u1ed9t l\u1ea7n<\/strong>&nbsp;: L\u00fd t\u01b0\u1edfng nh\u1ea5t l\u00e0 b\u1ea5t k\u1ef3 container \u0111\u01a1n l\u1ebb n\u00e0o trong m\u1ed9t \u1ee9ng d\u1ee5ng l\u1edbn h\u01a1n \u0111\u1ec1u c\u00f3 th\u1ec3 b\u1ecb l\u1ed7i m\u00e0 kh\u00f4ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn hi\u1ec7u su\u1ea5t c\u1ee7a \u1ee9ng d\u1ee5ng. S\u1eed d\u1ee5ng&nbsp;<code>restart: on-failure<\/code>t\u00f9y ch\u1ecdn trong&nbsp;<code>docker-compose.yml<\/code>t\u1ec7p, c\u0169ng nh\u01b0 c\u00f3 s\u1ed1 l\u01b0\u1ee3ng b\u1ea3n sao, gi\u00fap m\u1ed9t s\u1ed1 container trong d\u1ecbch v\u1ee5 si\u00eau nh\u1ecf v\u00ed d\u1ee5 c\u00f3 th\u1ec3 b\u1ecb l\u1ed7i m\u1ed9t c\u00e1ch b\u00ecnh th\u01b0\u1eddng trong khi v\u1eabn ph\u1ee5c v\u1ee5 \u1ee9ng d\u1ee5ng web \u2013 m\u00e0 kh\u00f4ng l\u00e0m gi\u1ea3m ch\u1ea5t l\u01b0\u1ee3ng c\u1ee7a ng\u01b0\u1eddi d\u00f9ng cu\u1ed1i.Ghi ch\u00faCh\u1ec9 th\u1ecb \u0111\u1ebfm b\u1ea3n sao ch\u1ec9 c\u00f3 hi\u1ec7u l\u1ef1c khi c\u1ea5u h\u00ecnh n\u00e0y \u0111\u01b0\u1ee3c tri\u1ec3n khai nh\u01b0 m\u1ed9t ph\u1ea7n c\u1ee7a&nbsp;<a href=\"https:\/\/www.linode.com\/docs\/guides\/how-to-create-a-docker-swarm-manager-and-nodes-on-linode\/\">Docker Swarm<\/a>&nbsp;, \u0111i\u1ec1u n\u00e0y kh\u00f4ng \u0111\u01b0\u1ee3c \u0111\u1ec1 c\u1eadp trong h\u01b0\u1edbng d\u1eabn n\u00e0y.<\/li>\n<li><strong>B\u1eaft \u0111\u1ea7u nhanh<\/strong>&nbsp;: Tr\u00e1nh c\u00e1c b\u01b0\u1edbc c\u00e0i \u0111\u1eb7t b\u1ed5 sung trong t\u1ec7p Docker, lo\u1ea1i b\u1ecf c\u00e1c ph\u1ee5 thu\u1ed9c kh\u00f4ng c\u1ea7n thi\u1ebft v\u00e0 x\u00e2y d\u1ef1ng h\u00ecnh \u1ea3nh m\u1ee5c ti\u00eau c\u00f3 th\u1ec3 t\u00e1i s\u1eed d\u1ee5ng l\u00e0 ba b\u01b0\u1edbc quan tr\u1ecdng nh\u1ea5t trong vi\u1ec7c t\u1ea1o \u1ee9ng d\u1ee5ng web c\u00f3 th\u1eddi gian kh\u1edfi t\u1ea1o nhanh trong Docker. \u1ee8ng d\u1ee5ng v\u00ed d\u1ee5 s\u1eed d\u1ee5ng Dockerfiles ng\u1eafn g\u1ecdn, s\u00fac t\u00edch, \u0111\u01b0\u1ee3c d\u1ef1ng s\u1eb5n \u0111\u1ec3 gi\u1ea3m thi\u1ec3u th\u1eddi gian kh\u1edfi t\u1ea1o.<\/li>\n<li><strong>D\u1eebng nhanh<\/strong>&nbsp;: X\u00e1c th\u1ef1c r\u1eb1ng a&nbsp;<code>docker kill --signal=SIGINT {APPNAME}<\/code>d\u1eebng \u1ee9ng d\u1ee5ng m\u1ed9t c\u00e1ch b\u00ecnh th\u01b0\u1eddng. \u0110i\u1ec1u n\u00e0y, c\u00f9ng v\u1edbi \u0111i\u1ec1u ki\u1ec7n kh\u1edfi \u0111\u1ed9ng l\u1ea1i v\u00e0 \u0111i\u1ec1u ki\u1ec7n sao ch\u00e9p, s\u1ebd \u0111\u1ea3m b\u1ea3o r\u1eb1ng khi container b\u1ecb l\u1ed7i, ch\u00fang s\u1ebd \u0111\u01b0\u1ee3c \u0111\u01b0a tr\u1edf l\u1ea1i tr\u1ef1c tuy\u1ebfn m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3.<\/li>\n<li><strong>Nh\u1eb9<\/strong>&nbsp;: S\u1eed d\u1ee5ng container c\u01a1 s\u1edf nh\u1ecf nh\u1ea5t cung c\u1ea5p t\u1ea5t c\u1ea3 c\u00e1c ti\u1ec7n \u00edch c\u1ea7n thi\u1ebft \u0111\u1ec3 x\u00e2y d\u1ef1ng v\u00e0 ch\u1ea1y \u1ee9ng d\u1ee5ng c\u1ee7a b\u1ea1n. Nhi\u1ec1u h\u00ecnh \u1ea3nh Docker d\u1ef1a tr\u00ean&nbsp;<a href=\"https:\/\/alpinelinux.org\/about\/\" target=\"_blank\" rel=\"noreferrer noopener\">Alpine Linux<\/a>&nbsp;, m\u1ed9t b\u1ea3n ph\u00e2n ph\u1ed1i Linux nh\u1eb9 v\u00e0 \u0111\u01a1n gi\u1ea3n ch\u1ec9 chi\u1ebfm 5MB trong m\u1ed9t h\u00ecnh \u1ea3nh Docker. S\u1eed d\u1ee5ng m\u1ed9t b\u1ea3n ph\u00e2n ph\u1ed1i nh\u1ecf gi\u00fap ti\u1ebft ki\u1ec7m chi ph\u00ed m\u1ea1ng v\u00e0 ho\u1ea1t \u0111\u1ed9ng, \u0111\u1ed3ng th\u1eddi t\u0103ng \u0111\u00e1ng k\u1ec3 hi\u1ec7u su\u1ea5t container. \u1ee8ng d\u1ee5ng v\u00ed d\u1ee5 s\u1eed d\u1ee5ng h\u00ecnh \u1ea3nh alpine khi c\u00f3 th\u1ec3 (NGINX, Redis v\u00e0 PostgreSQL) v\u00e0 h\u00ecnh \u1ea3nh c\u01a1 s\u1edf python-slim cho \u1ee9ng d\u1ee5ng Gunicorn \/ Flask.<\/li>\n<li><strong>Kh\u00f4ng tr\u1ea1ng th\u00e1i<\/strong>&nbsp;: V\u00ec ch\u00fang l\u00e0 t\u1ea1m th\u1eddi, c\u00e1c container th\u01b0\u1eddng kh\u00f4ng duy tr\u00ec tr\u1ea1ng th\u00e1i. Tr\u1ea1ng th\u00e1i c\u1ee7a \u1ee9ng d\u1ee5ng ph\u1ea3i \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong m\u1ed9t kh\u1ed1i d\u1eef li\u1ec7u ri\u00eang bi\u1ec7t, li\u00ean t\u1ee5c, nh\u01b0 tr\u01b0\u1eddng h\u1ee3p kho d\u1eef li\u1ec7u PostgreSQL c\u1ee7a microservice. Kho l\u01b0u tr\u1eef kh\u00f3a-gi\u00e1 tr\u1ecb Redis duy tr\u00ec d\u1eef li\u1ec7u trong m\u1ed9t container, nh\u01b0ng d\u1eef li\u1ec7u n\u00e0y kh\u00f4ng quan tr\u1ecdng \u0111\u1ed1i v\u1edbi \u1ee9ng d\u1ee5ng; kho l\u01b0u tr\u1eef Redis s\u1ebd t\u1ef1 \u0111\u1ed9ng chuy\u1ec3n ng\u01b0\u1ee3c v\u1ec1 c\u01a1 s\u1edf d\u1eef li\u1ec7u n\u1ebfu container kh\u00f4ng th\u1ec3 ph\u1ea3n h\u1ed3i.<\/li>\n<li><strong>Portable<\/strong>&nbsp;: T\u1ea5t c\u1ea3 c\u00e1c dependency c\u1ee7a \u1ee9ng d\u1ee5ng c\u1ea7n thi\u1ebft cho th\u1eddi gian ch\u1ea1y container ph\u1ea3i c\u00f3 s\u1eb5n c\u1ee5c b\u1ed9. T\u1ea5t c\u1ea3 c\u00e1c dependency c\u1ee7a microservice m\u1eabu v\u00e0 c\u00e1c t\u1eadp l\u1ec7nh kh\u1edfi \u0111\u1ed9ng \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong th\u01b0 m\u1ee5c cho t\u1eebng th\u00e0nh ph\u1ea7n. Nh\u1eefng dependency n\u00e0y c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c ki\u1ec3m tra trong ki\u1ec3m so\u00e1t phi\u00ean b\u1ea3n, gi\u00fap d\u1ec5 d\u00e0ng chia s\u1ebb v\u00e0 tri\u1ec3n khai \u1ee9ng d\u1ee5ng.<\/li>\n<li><strong>M\u00f4-\u0111un<\/strong>&nbsp;: M\u1ed7i container ph\u1ea3i c\u00f3 m\u1ed9t tr\u00e1ch nhi\u1ec7m v\u00e0 m\u1ed9t quy tr\u00ecnh. Trong microservice n\u00e0y, m\u1ed7i quy tr\u00ecnh ch\u00ednh (NGINX, Python, Redis v\u00e0 PostgreSQL) \u0111\u01b0\u1ee3c tri\u1ec3n khai trong m\u1ed9t container ri\u00eang bi\u1ec7t.<\/li>\n<li><strong>Ghi nh\u1eadt k\u00fd<\/strong>&nbsp;: T\u1ea5t c\u1ea3 c\u00e1c container ph\u1ea3i ghi v\u00e0o&nbsp;<code>STDOUT<\/code>. S\u1ef1 th\u1ed1ng nh\u1ea5t n\u00e0y gi\u00fap d\u1ec5 d\u00e0ng xem nh\u1eadt k\u00fd c\u1ee7a t\u1ea5t c\u1ea3 c\u00e1c quy tr\u00ecnh trong m\u1ed9t lu\u1ed3ng duy nh\u1ea5t.<\/li>\n<li><strong>Resilient<\/strong>&nbsp;: \u1ee8ng d\u1ee5ng v\u00ed d\u1ee5 s\u1ebd kh\u1edfi \u0111\u1ed9ng l\u1ea1i c\u00e1c container c\u1ee7a n\u00f3 n\u1ebfu ch\u00fang b\u1ecb tho\u00e1t v\u00ec b\u1ea5t k\u1ef3 l\u00fd do g\u00ec. \u0110i\u1ec1u n\u00e0y gi\u00fap cung c\u1ea5p cho \u1ee9ng d\u1ee5ng Dockerized c\u1ee7a b\u1ea1n t\u00ednh kh\u1ea3 d\u1ee5ng v\u00e0 hi\u1ec7u su\u1ea5t cao, ngay c\u1ea3 trong th\u1eddi gian b\u1ea3o tr\u00ec.<\/li>\n<\/ol>\n<h2 id=\"more-information\">Th\u00f4ng tin th\u00eam<\/h2>\n<p>B\u1ea1n c\u00f3 th\u1ec3 mu\u1ed1n tham kh\u1ea3o c\u00e1c ngu\u1ed3n sau \u0111\u1ec3 bi\u1ebft th\u00eam th\u00f4ng tin v\u1ec1 ch\u1ee7 \u0111\u1ec1 n\u00e0y. M\u1eb7c d\u00f9 ch\u00fang t\u00f4i cung c\u1ea5p v\u1edbi hy v\u1ecdng r\u1eb1ng ch\u00fang s\u1ebd h\u1eefu \u00edch, nh\u01b0ng xin l\u01b0u \u00fd r\u1eb1ng ch\u00fang t\u00f4i kh\u00f4ng th\u1ec3 \u0111\u1ea3m b\u1ea3o t\u00ednh ch\u00ednh x\u00e1c ho\u1eb7c t\u00ednh k\u1ecbp th\u1eddi c\u1ee7a c\u00e1c t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef b\u00ean ngo\u00e0i.<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/bobstrecansky\/flask-microservice\" target=\"_blank\" rel=\"noreferrer noopener\">Kho l\u01b0u tr\u1eef Github cho d\u1ecbch v\u1ee5 vi m\u00f4 v\u00ed d\u1ee5<\/a><\/li>\n<li><a href=\"https:\/\/medium.com\/aws-activate-startup-blog\/using-containers-to-build-a-microservices-architecture-6e1b8bacb7d1\" target=\"_blank\" rel=\"noreferrer noopener\">S\u1eed d\u1ee5ng Container \u0111\u1ec3 x\u00e2y d\u1ef1ng Ki\u1ebfn tr\u00fac Microservices<\/a><\/li>\n<\/ul>\n<p>Ngu\u1ed3n: https:\/\/www.linode.com\/docs\/guides\/deploying-microservices-with-docker\/<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microservice l\u00e0 g\u00ec? Microservices l\u00e0 m\u1ed9t ki\u1ebfn \u200b\u200btr\u00fac ng\u00e0y c\u00e0ng ph\u1ed5 bi\u1ebfn \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng quy m\u00f4 l\u1edbn. Thay v\u00ec s\u1eed d\u1ee5ng m\u1ed9t c\u01a1 s\u1edf m\u00e3 \u0111\u01a1n kh\u1ed1i, c\u00e1c \u1ee9ng d\u1ee5ng \u0111\u01b0\u1ee3c chia th\u00e0nh m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c th\u00e0nh ph\u1ea7n nh\u1ecf h\u01a1n \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 microservices. C\u00e1ch ti\u1ebfp c\u1eadn n\u00e0y mang l\u1ea1i<\/p>\n","protected":false},"author":1,"featured_media":36274,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[],"class_list":["post-35045","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-containers"],"_links":{"self":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/35045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/comments?post=35045"}],"version-history":[{"count":0,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/posts\/35045\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media\/36274"}],"wp:attachment":[{"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/media?parent=35045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/categories?post=35045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jupitek.maudemo.vip\/index.php\/wp-json\/wp\/v2\/tags?post=35045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}