[{"data":1,"prerenderedAt":703},["ShallowReactive",2],{"news-item-\u002Fnews\u002Flaunch-with-docker":3},{"id":4,"title":5,"body":6,"category":690,"created by":691,"date":692,"description":693,"extension":694,"meta":695,"navigation":696,"path":697,"sections":698,"seo":699,"stem":700,"thumbnail":701,"__hash__":702},"content_en\u002Fnews\u002Flaunch-with-docker.md","Launch Web with Docker",{"type":7,"value":8,"toc":675},"minimark",[9,17,21,27,30,33,36,39,42,48,57,63,66,72,75,81,90,171,177,180,183,223,226,236,242,248,254,260,266,272,278,284,295,301,307,313,316,322,325,331,334,340,343,349,352,358,361,367,370,376,379,385,388,394,401,407,410,418,423,428,433,438,442,445,448,454,457,463,466,472,475,481,484,487,493,496,502,511,515,518,524,527,533,536,542,545,548,551,554,560,563,566,569,572,578,581,586,592,597,603,606,612,615,621,624,629,633,638,642,645,649,653,658,663,669],[10,11,13],"h2",{"id":12},"i-what-is-docker",[14,15,16],"strong",{},"I. WHAT IS DOCKER?",[18,19,20],"p",{},"Docker is an open platform for developing, deploying, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.",[10,22,24],{"id":23},"ii-benefits-of-docker",[14,25,26],{},"II. BENEFITS OF DOCKER",[18,28,29],{},"Unlike virtual machines, Docker starts and stops in seconds.",[18,31,32],{},"You can launch the container on each system that you want.",[18,34,35],{},"Containers can be built and removed faster than virtual machines.",[18,37,38],{},"Easy to set up working environment. Just config once only and never have to reinstall dependencies.",[18,40,41],{},"It keeps your work-space cleaner when you delete the environment that affects other parts.",[10,43,45],{"id":44},"iii-install",[14,46,47],{},"III. INSTALL",[18,49,50,51],{},"See the instructions: ",[52,53,54],"a",{"href":54,"rel":55},"https:\u002F\u002Fdocs.docker.com\u002Fget-docker\u002F",[56],"nofollow",[10,58,60],{"id":59},"iv-image",[14,61,62],{},"IV. IMAGE",[18,64,65],{},"Docker Image is a read-only template used to create containers. Image is structured of layers and all layers are read-only. Create an image can be based on another image with some additional customization. In short, Docker Image is a place to store environment settings such as OS, packages, software to run…",[10,67,69],{"id":68},"v-container",[14,70,71],{},"V. CONTAINER",[18,73,74],{},"Docker Container is created from Docker Image, which contains everything needed to be able to run an application. As virtualization but the Container is very light, can be considered as a system process. It only takes a few seconds to start, stop or restart a Container. With a physical server, instead of running a few traditional virtual machines, we can run several dozen, even several hundred Docker Containers.",[10,76,78],{"id":77},"vi-compare-container-and-virtual-machine",[14,79,80],{},"VI. COMPARE CONTAINER AND VIRTUAL MACHINE",[82,83],"img",{"className":84,"alt":87,"src":88,"style":89},[85,86],"block","mx-auto","","https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F28100010\u002Fcompare.jpg","width: 100%;",[91,92,93,112],"table",{},[94,95,96],"thead",{},[97,98,99,102,107],"tr",{},[100,101],"th",{},[100,103,104],{},[14,105,106],{},"CONTAINER",[100,108,109],{},[14,110,111],{},"VIRTUAL MACHINE",[113,114,115,127,138,149,160],"tbody",{},[97,116,117,121,124],{},[118,119,120],"td",{},"Resource",[118,122,123],{},"The process in the container directly uses real resources, but the operating system can stipulate each process a different resource limit  (or unlimited).",[118,125,126],{},"Everything is limited by virtual hardware.",[97,128,129,132,135],{},[118,130,131],{},"Execution",[118,133,134],{},"The real OS runs the software.",[118,136,137],{},"Real OS → Virtual OS → Virtual OS running the software. (For VPS, Hypervisor type 1 replaces the real OS)",[97,139,140,143,146],{},[118,141,142],{},"Performance",[118,144,145],{},"Real software runs on real hardware. Starting speed is almost a normal software.",[118,147,148],{},"Real hardware has to carry a virtual OS. Since the computer was booted up, it took time until the software was used.",[97,150,151,154,157],{},[118,152,153],{},"Security",[118,155,156],{},"Processes in the same container can still affect each other. But normally each container should only run one process. Processes of different containers cannot affect each other.",[118,158,159],{},"Software has malicious code can affect other process resources in the same VM.",[97,161,162,165,168],{},[118,163,164],{},"Support software",[118,166,167],{},"Docker Engine, LXC Linux Container, Apache Mesos, CRI-O (Kubernetes)…",[118,169,170],{},"VirtualBox, VMWare, Microsoft Hyper-V, Parallels, Linux KVM, Docker Machine…",[10,172,174],{"id":173},"vii-dockerfile",[14,175,176],{},"VII. DOCKERFILE",[18,178,179],{},"– Dockerfile is a config file for Docker to build the image. It uses a basic image to build the initial image class. Some basic images: python, ubuntu and alpine. Then if there are additional layers then it is stacked on top of the base layer.",[18,181,182],{},"– The config :",[184,185,186,190,193,196,199,202,205,208,211,214,217,220],"ul",{},[187,188,189],"li",{},"FROM — Specifies the original image: python, ubuntu, alpine…",[187,191,192],{},"LABEL — Provide metadata for the image. Can be used to add maintainer information. To see the labels for the images, use the docker inspect command.",[187,194,195],{},"ENV — Set an environment variable.",[187,197,198],{},"RUN — Can create a command when building image. Used to install packages into containers.",[187,200,201],{},"COPY — Copy files and folders into the container.",[187,203,204],{}," ADD — Copy files and folders into the container.",[187,206,207],{},"CMD — Provide a command and argument for the executable container. Parameters can be overridden and only a CMD.",[187,209,210],{},"WORKDIR — Set up working directory for other directives such as: RUN, CMD, ENTRYPOINT, COPY, ADD, ...",[187,212,213],{},"ARG — Define the variables value to be used during image build.",[187,215,216],{},"ENTRYPOINT — Provide a command and argument for the executable container.",[187,218,219],{},"EXPOSE — Declares the port of the image.",[187,221,222],{},"VOLUME — Create a directory mount point for accessing and storing data.",[18,224,225],{},"Example:",[227,228,233],"pre",{"className":229,"code":231,"language":232},[230],"language-text","FROM node:12-alpine\nRUN apk add git\nRUN mkdir -p \u002Fhome\u002Fnode\u002Fapp\nWORKDIR \u002Fhome\u002Fnode\u002Fapp\nCOPY package*.json .\u002F\nRUN npm install\nCOPY . .\nENV HOST=0.0.0.0 PORT=3334\nEXPOSE $PORT\nCMD [ \"node\", \".\" ]\n","text",[234,235,231],"code",{"__ignoreMap":87},[10,237,239],{"id":238},"viii-the-other-concepts",[14,240,241],{},"VIII. THE OTHER CONCEPTS",[18,243,244,247],{},[14,245,246],{},"Docker Client",": Interacts with docker via command in terminal. Docker Client will use the API to send commands to Docker Daemon.",[18,249,250,253],{},[14,251,252],{},"Docker Daemon",": Docker server for requests from the Docker API. It manages images, containers, networks and volumes.",[18,255,256,259],{},[14,257,258],{},"Docker Volumes",": A place that stores data continuously for using and creating apps.",[18,261,262,265],{},[14,263,264],{},"Docker Registry",": Docker Images's private storage. Images are pushed into the registry and the client pulls images from the registry. You can use your own registry or the registry of your provider such as: AWS, Google Cloud, Microsoft Azure.",[18,267,268,271],{},[14,269,270],{},"Docker Hub",":  Docker Images largest registry (default). Can find images and store your own images on Docker Hub (free).",[18,273,274,277],{},[14,275,276],{},"Docker Repository",": set of Docker Images with the same name but different tags. Example: node: 12-alpine.",[18,279,280,283],{},[14,281,282],{},"Docker Networking",": allows to connect containers together. This connection can be on a host or more hosts.",[18,285,286,289,290,294],{},[14,287,288],{},"Docker Compose",": The tool allows to run apps with multiple Docker containers easily. Docker Compose allows you to configure commands in the ",[291,292,293],"em",{},"docker-compose.yml"," file for reuse. Available with Docker installed.",[18,296,297,300],{},[14,298,299],{},"Docker Swarm",": coordinate container deployment.",[18,302,303,306],{},[14,304,305],{},"Docker Services",": The  containers in production. A service only runs an image but it encrypts the way to run the image - which port to use, how many copies of the container to run the service has the necessary and immediate performance.",[10,308,310],{"id":309},"ix-basic-commands-in-docker",[14,311,312],{},"IX. BASIC COMMANDS IN DOCKER",[18,314,315],{},"List image\u002Fcontainer:",[227,317,320],{"className":318,"code":319,"language":232},[230],"docker image\u002Fcontainer ls\n",[234,321,319],{"__ignoreMap":87},[18,323,324],{},"List all containers:",[227,326,329],{"className":327,"code":328,"language":232},[230],"docker ps –a\n",[234,330,328],{"__ignoreMap":87},[18,332,333],{},"Stop a container:",[227,335,338],{"className":336,"code":337,"language":232},[230],"docker stop \u003Ccontainer name>\n",[234,339,337],{"__ignoreMap":87},[18,341,342],{},"Run the container from the image and change the container name:",[227,344,347],{"className":345,"code":346,"language":232},[230],"docker run –name \u003Ccontainer name> \u003Cimage name>\n",[234,348,346],{"__ignoreMap":87},[18,350,351],{},"Stop all container:",[227,353,356],{"className":354,"code":355,"language":232},[230],"docker stop $(docker ps –a –q)\n",[234,357,355],{"__ignoreMap":87},[18,359,360],{},"Show log a container:",[227,362,365],{"className":363,"code":364,"language":232},[230],"docker logs \u003Ccontainer name>\n",[234,366,364],{"__ignoreMap":87},[18,368,369],{},"Build an image from container:",[227,371,374],{"className":372,"code":373,"language":232},[230],"docker build -t \u003Ccontainer name> .\n",[234,375,373],{"__ignoreMap":87},[18,377,378],{},"Create a container running in the background:",[227,380,383],{"className":381,"code":382,"language":232},[230],"docker run -d \u003Cimage name>\n",[234,384,382],{"__ignoreMap":87},[18,386,387],{},"Start a container:",[227,389,392],{"className":390,"code":391,"language":232},[230],"docker start \u003Ccontainer name>\n",[234,393,391],{"__ignoreMap":87},[18,395,396,397],{},"See more: ",[52,398,399],{"href":399,"rel":400},"https:\u002F\u002Fdocs.docker.com\u002Freference\u002F",[56],[10,402,404],{"id":403},"x-initial-install",[14,405,406],{},"X. INITIAL INSTALL",[18,408,409],{},"Step 1: Access to EC2 of AWS.",[184,411,412,415],{},[187,413,414],{},"Open Tera Term application to access.",[187,416,417],{},"Enter host server into Host textbox.",[82,419],{"className":420,"alt":87,"src":421,"style":422},[85,86],"https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F04163035\u002Fhost-teraterm.png","width: 80%;",[184,424,425],{},[187,426,427],{},"Enter username and key, then OK press.",[82,429],{"className":430,"alt":87,"src":431,"style":432},[85,86],"https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F04163312\u002Fkey-teraterm.png","width: 60%;",[184,434,435],{},[187,436,437],{},"Screen after access.",[82,439],{"className":440,"alt":87,"src":441,"style":422},[85,86],"https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F04163531\u002FTerminal.png",[18,443,444],{},"Step 2: Install docker.",[18,446,447],{},"1. Update the packages on your instance",[227,449,452],{"className":450,"code":451,"language":232},[230],"sudo yum update -y\n",[234,453,451],{"__ignoreMap":87},[18,455,456],{},"2. Install Docker",[227,458,461],{"className":459,"code":460,"language":232},[230],"sudo yum install docker -y\n",[234,462,460],{"__ignoreMap":87},[18,464,465],{},"3. Start the Docker Service",[227,467,470],{"className":468,"code":469,"language":232},[230],"sudo service docker start\n",[234,471,469],{"__ignoreMap":87},[18,473,474],{},"4. Add the ec2-user to the docker group so you can execute Docker commands without using sudo.",[227,476,479],{"className":477,"code":478,"language":232},[230],"sudo usermod -a -G docker ec2-user\n",[234,480,478],{"__ignoreMap":87},[18,482,483],{},"Step 3: Install git and clone\u002Fpull source code.",[18,485,486],{},"1. Install git",[227,488,491],{"className":489,"code":490,"language":232},[230],"sudo yum install git\n",[234,492,490],{"__ignoreMap":87},[18,494,495],{},"2. Clone\u002Fpull source code.",[227,497,500],{"className":498,"code":499,"language":232},[230],"git clone https:\u002F\u002FusernameToken:passwordToken@gitlab.com\u002F\u003Cproject name>\u002F\u003Cgit name>.git\nor\ngit pull origin develop\n",[234,501,499],{"__ignoreMap":87},[18,503,504,505,510],{},"** With usernameToken is name's deploy token and passwordToken is a random string of characters.(See more ",[52,506,509],{"href":507,"rel":508},"https:\u002F\u002Fdocs.gitlab.com\u002Fee\u002Fuser\u002Fproject\u002Fdeploy_tokens\u002F",[56],"here",").",[10,512,514],{"id":513},"xi-deploy","XI. DEPLOY",[18,516,517],{},"Step 1: Go to the directory containing the source code",[227,519,522],{"className":520,"code":521,"language":232},[230],"cd \u003Cproject folder>\n",[234,523,521],{"__ignoreMap":87},[18,525,526],{},"Dockerfile-dev file in source is configured as follows:",[227,528,531],{"className":529,"code":530,"language":232},[230],"# Check out https:\u002F\u002Fhub.docker.com\u002F_\u002Fnode to select a new base image\nFROM node:12-alpine\nRUN apk add git\n\n# Set to a non-root built-in user `node`\nUSER node\n\n# Create app directory (with user `node`)\nRUN mkdir -p \u002Fhome\u002Fnode\u002Fapp\nWORKDIR \u002Fhome\u002Fnode\u002Fapp\n\nENV NODE_ENV=\"\u003CEnvironment name>\"\nENV PORT=\"3334\" ENV DEBUG=\"front:*\"\nENV SESSION_SECRET=\"session-secret\"\n\n# Install app dependencies\n# A wildcard is used to ensure both package.json AND package-lock.json are copied\n# where available (npm@5+)\nCOPY package*.json .\u002F\nRUN npm install\n\n# Bundle app source code\nCOPY . .\n\n# Bind to all network interfaces so that it can be mapped to the host OS\nENV HOST=0.0.0.0 PORT=3334\nEXPOSE $PORT\nCMD [ \"node\", \".\" ]\n",[234,532,530],{"__ignoreMap":87},[18,534,535],{},"Step 2: Build images source",[227,537,540],{"className":538,"code":539,"language":232},[230],"docker build --no-cache -t \u003CImage name> -f Dockerfile.dev . (Using for development)\n",[234,541,539],{"__ignoreMap":87},[18,543,544],{},"* -t: option tags of image.",[18,546,547],{},"* . : source folder",[18,549,550],{},"* --no-cache: not save cache.",[18,552,553],{},"Step 3: Run container from image source.",[227,555,558],{"className":556,"code":557,"language":232},[230],"docker run -dp \u003CHost port>:\u003CContainer port> --name \u003Ccontainer name> \u003CImage name>\n",[234,559,557],{"__ignoreMap":87},[18,561,562],{},"* --name: set name for container, this is  evaluate-system. Name is unique, If not, docker generate.",[18,564,565],{},"* -p: open port container.",[18,567,568],{},"* -d: turn on background mode",[18,570,571],{},"Step 4: Go to nginx folder in source.",[227,573,576],{"className":574,"code":575,"language":232},[230],"cd nginx\n",[234,577,575],{"__ignoreMap":87},[18,579,580],{},"In nginx folder include 2 file are default.conf and Dockerfile",[184,582,583],{},[187,584,585],{},"File default.conf",[227,587,590],{"className":588,"code":589,"language":232},[230],"server {\n    location \u002F {\n          proxy_set_header Host $host;\n          proxy_set_header X-Real-IP $remote_addr;\n          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n          proxy_set_header X-Forwarded-Proto $scheme;\n          proxy_pass http:\u002F\u002Fapp:3334;\n    }\n}\n",[234,591,589],{"__ignoreMap":87},[184,593,594],{},[187,595,596],{},"File Dockerfile",[227,598,601],{"className":599,"code":600,"language":232},[230],"FROM nginx\nRUN rm \u002Fetc\u002Fnginx\u002Fconf.d\u002F* \nCOPY default.conf \u002Fetc\u002Fnginx\u002Fconf.d\u002F\n",[234,602,600],{"__ignoreMap":87},[18,604,605],{},"Build image nginx for source",[227,607,610],{"className":608,"code":609,"language":232},[230],"docker build -t es\u002Fnginx .\n",[234,611,609],{"__ignoreMap":87},[18,613,614],{},"Run container es\u002Fnginx",[227,616,619],{"className":617,"code":618,"language":232},[230],"docker run -dp 80:80 --link \u003Ccontainer name>:app --name nginx-proxy es\u002Fnginx\n",[234,620,618],{"__ignoreMap":87},[18,622,623],{},"Step 5: Show images and containers.",[184,625,626],{},[187,627,628],{},"List image",[82,630],{"className":631,"alt":87,"src":632,"style":89},[85,86],"https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F28122425\u002Fimages-ec2.png",[184,634,635],{},[187,636,637],{}," List container.",[82,639],{"className":640,"alt":87,"src":641,"style":89},[85,86],"https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F28122548\u002Fcontainer-ec2-1024x87.png",[18,643,644],{},"Step 6: Access to web",[82,646],{"className":647,"alt":87,"src":648,"style":89},[85,86],"https:\u002F\u002Fs3-ap-southeast-1.amazonaws.com\u002Fhomepage-media\u002Fwp-content\u002Fuploads\u002F2021\u002F01\u002F28122802\u002Flogin-ec2-1024x490.jpg",[10,650,652],{"id":651},"xii-references","XII. REFERENCES",[18,654,655],{},[52,656,54],{"href":54,"rel":657},[56],[18,659,660],{},[52,661,399],{"href":399,"rel":662},[56],[18,664,665],{},[52,666,667],{"href":667,"rel":668},"https:\u002F\u002Fdocs.docker.com\u002F",[56],[18,670,671],{},[52,672,673],{"href":673,"rel":674},"https:\u002F\u002Fegghead.io\u002Flessons\u002Fnode-js-setup-an-nginx-proxy-for-a-node-js-app-with-docker",[56],{"title":87,"searchDepth":676,"depth":676,"links":677},2,[678,679,680,681,682,683,684,685,686,687,688,689],{"id":12,"depth":676,"text":16},{"id":23,"depth":676,"text":26},{"id":44,"depth":676,"text":47},{"id":59,"depth":676,"text":62},{"id":68,"depth":676,"text":71},{"id":77,"depth":676,"text":80},{"id":173,"depth":676,"text":176},{"id":238,"depth":676,"text":241},{"id":309,"depth":676,"text":312},{"id":403,"depth":676,"text":406},{"id":513,"depth":676,"text":514},{"id":651,"depth":676,"text":652},"tech talk","Briswell Vietnam Co Ltd","2021-03-18","I. WHAT IS DOCKER? Docker is an open platform for developing, deploying, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications.","md",{},true,"\u002Fnews\u002Flaunch-with-docker",null,{"title":5,"description":693},"news\u002Flaunch-with-docker","https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2026\u002F06\u002F05103100\u002Flogo-docker.png","07MRsPUQt7OayDXCCldTJ9SgA3eHNEkXNZXNb1Hrxu8",1782263085994]