[{"data":1,"prerenderedAt":434},["ShallowReactive",2],{"wiki-page-/en-us/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie":3,"wiki-doc-items-/en-us/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie":352,"language-switcher-data-/en-us/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie":418,"wiki-i18n-paths-/en-us/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie":433},{"id":4,"title":5,"body":6,"canonicalPath":331,"chapter":332,"chapterSort":333,"date":334,"description":323,"docI18nKey":335,"docKey":336,"docRoot":337,"docTitle":338,"extension":339,"i18nKey":340,"isBlogPost":341,"isWikiDoc":342,"isWikiIndex":341,"layout":343,"legacyPath":343,"locale":344,"localeSlug":345,"meta":346,"navigation":342,"path":331,"seo":347,"sourcePath":348,"sourceStem":340,"stem":349,"wikiDepth":350,"__hash__":351},"content/_i18n/en-us/wiki/2024-10-03-Docker教程/ch1-简介.md","Introduction",{"type":7,"value":8,"toc":322},"minimark",[9,14,26,33,42,45,53,56,59,63,76,80,133,136,139,142,145,153,157,195,201,205,258,263,266,269,274,277,283,290,293,298,301,304,308],[10,11,13],"h3",{"id":12},"what-is-docker","🐳 What is Docker?",[15,16,17,18,22,23],"p",{},"Docker is an open-source ",[19,20,21],"strong",{},"application container engine"," that allows developers to package an application and all its dependencies into a single \"container,\" enabling ",[19,24,25],{},"build once, run anywhere.",[15,27,28,29,32],{},"\"",[19,30,31],{},"Build once, run anywhere","\" means:",[34,35,36],"ol",{},[37,38,39],"li",{},[19,40,41],{},"Previously:",[15,43,44],{},"Previously, to run ROS2 + OpenCV + CUDA + CuDNN, I had to install and configure each environment one by one on a single computer. If I wanted to run it on another computer, I would have to go through the same setup process all over again. And if my system environment crashed and I needed to reinstall the OS, I would have to repeat the entire configuration process yet again — which was very tedious.",[34,46,48],{"start":47},2,[37,49,50],{},[19,51,52],{},"After using Docker:",[15,54,55],{},"(The concepts of Docker images and Docker containers are explained further below. For now, just accept the concepts of images and containers as you read the following passage.)",[15,57,58],{},"I just need to configure this ROS2 + OpenCV + CUDA + CuDNN environment once on my computer using Docker, then generate an image from Docker and package it. From then on, on any computer, I can directly use this image to create a container, and that container will contain the ROS2 + OpenCV + CUDA + CuDNN environment I need. If my container environment crashes, I just delete the broken container and generate a new one from the image again. I only need to configure it once, and I can install this environment with one click in the future.",[10,60,62],{"id":61},"how-does-it-work","📦 How does it work?",[64,65,66,69],"ul",{},[37,67,68],{},"Traditional approach: Running software requires installing various libraries and configuring environments on different systems, which is very cumbersome.",[37,70,71,72,75],{},"Docker method: Package into a \"container,\" encapsulating both the environment and the application together, ",[19,73,74],{},"ensuring stable operation no matter where it runs",".",[10,77,79],{"id":78},"a-few-basic-concepts-of-docker","🔧 A few basic concepts of Docker",[81,82,83,97],"table",{},[84,85,86],"thead",{},[87,88,89,94],"tr",{},[90,91,93],"th",{"align":92},"left","concept",[90,95,96],{"align":92},"Explanation",[98,99,100,109,117,125],"tbody",{},[87,101,102,106],{},[103,104,105],"td",{"align":92},"Mirror image",[103,107,108],{"align":92},"Image, a template for running containers, like an application snapshot.",[87,110,111,114],{},[103,112,113],{"align":92},"container",[103,115,116],{"align":92},"Container, a running instance of an image, has its own file system, network, and more.",[87,118,119,122],{},[103,120,121],{"align":92},"Dockerfile",[103,123,124],{"align":92},"A script for building the image, specifying which packages to install, which environment variables to set, and so on.",[87,126,127,130],{},[103,128,129],{"align":92},"repository",[103,131,132],{"align":92},"Registry, a place to store images, such as Docker Hub.",[15,134,135],{},"Abstract Understanding:",[15,137,138],{},"A Docker image is roughly equivalent to a C++ class.",[15,140,141],{},"A Docker container is roughly equivalent to a C++ class instance (i.e., an object).",[15,143,144],{},"Visualization: An image can be likened to an ISO file used to install an operating system on a computer. A container can be likened to a system that has been installed on the computer and is ready to run.",[15,146,147,148,152],{},"When turning an image into a container, you need to use the ",[149,150,151],"code",{},"docker run"," command with many parameters. This is understandable because it tells your computer exactly what hardware configuration it has.",[10,154,156],{"id":155},"understanding-by-analogy","🔍 Understanding by Analogy",[81,158,159,169],{},[84,160,161],{},[87,162,163,166],{},[90,164,165],{"align":92},"Traditional deployment",[90,167,168],{"align":92},"Docker deployment",[98,170,171,179,187],{},[87,172,173,176],{},[103,174,175],{"align":92},"Manually install dependencies and debug version mismatch issues.",[103,177,178],{"align":92},"Package the environment and code together at once.",[87,180,181,184],{},[103,182,183],{"align":92},"The program runs \"bare metal\" on the system.",[103,185,186],{"align":92},"The program runs in isolation within a container.",[87,188,189,192],{},[103,190,191],{"align":92},"Easily \"runs on my machine\"",[103,193,194],{"align":92},"Ensure it \"runs anywhere\"",[15,196,197,198],{},"Just like a delivery package: ",[19,199,200],{},"You no longer care about how the contents are transported, because the packaging has already handled all the isolation for you.",[10,202,204],{"id":203},"the-core-advantages-of-docker","The core advantages of Docker",[81,206,207,216],{},[84,208,209],{},[87,210,211,214],{},[90,212,213],{"align":92},"Advantage",[90,215,96],{"align":92},[98,217,218,226,234,242,250],{},[87,219,220,223],{},[103,221,222],{"align":92},"Lightweight",[103,224,225],{"align":92},"Based on system kernel sharing, it has fast startup speed and low resource usage.",[87,227,228,231],{},[103,229,230],{"align":92},"cross-platform",[103,232,233],{"align":92},"Build once, run everywhere (consistent across Windows, Linux, and macOS).",[87,235,236,239],{},[103,237,238],{"align":92},"Easy to migrate and deploy",[103,240,241],{"align":92},"The application and environment are packaged together, eliminating concerns about dependency inconsistencies.",[87,243,244,247],{},[103,245,246],{"align":92},"Easy to version control",[103,248,249],{"align":92},"Mirror version is controllable and supports rollback.",[87,251,252,255],{},[103,253,254],{"align":92},"Rich ecosystem",[103,256,257],{"align":92},"There are tens of thousands of ready-made images available on Docker Hub.",[34,259,260],{},[37,261,262],{},"On Linux, it can be achieved with almost no performance loss.",[15,264,265],{},"The distribution in Docker shares the Linux kernel with the host machine.",[15,267,268],{},"CPU overhead is less than 1%. Memory is near-native with no overhead. Disk overhead is less than 2%. Network performance is near-native with no overhead. Graphics card overhead is less than 1%.",[34,270,271],{"start":47},[37,272,273],{},"Can be quickly deployed on most Linux distributions.",[15,275,276],{},"If you want to run ROS2, it was previously easier to deploy only on Ubuntu. However, now you can use any distribution, such as Fedora, ArchLinux, and others, to run ROS2 via Docker.",[34,278,280],{"start":279},3,[37,281,282],{},"Setting up the environment is simple.",[15,284,285,286,289],{},"Previously, you had to install ROS2, CUDA, CuDNN, OpenCV4, and more on Ubuntu by following a tutorial. But as long as you use Docker, you can directly pull a pre-configured development environment from someone else using the ",[149,287,288],{},"docker pull"," command — just one command and you're there.",[15,291,292],{},"You only need to configure the most basic components of a distribution, such as switching repository mirrors, setting up the input method, and installing the graphics driver (just enough to get the graphics card working—no need to configure CUDA or cuDNN locally).",[34,294,296],{"start":295},4,[37,297,254],{},[15,299,300],{},"The ecosystem is extremely rich. Even if you don't build things yourself, you can find pre-built images on Docker Hub, saving you the trouble of compiling.",[15,302,303],{},"For example, when configuring CUDA and cuDNN in the past, you had to first install the NVIDIA driver on your local machine, then install CUDA and cuDNN. Now, we only need to install the NVIDIA driver locally. NVIDIA officially provides pre-compiled CUDA and cuDNN images on DockerHub, so we can use them directly.",[10,305,307],{"id":306},"common-docker-use-cases","📁 Common Docker Use Cases",[64,309,310,313,316,319],{},[37,311,312],{},"Local development: quickly set up various development environments (such as Python + Jupyter, ROS + Gazebo)",[37,314,315],{},"Test deployment: automated testing, building, and deployment in CI/CD",[37,317,318],{},"Microservices architecture: one container per service, flexible composition",[37,320,321],{},"Research Tool Packaging: Reproducing someone else's paper environment, or packaging your own project for others to use.",{"title":323,"searchDepth":47,"depth":47,"links":324},"",[325,326,327,328,329,330],{"id":12,"depth":279,"text":13},{"id":61,"depth":279,"text":62},{"id":78,"depth":279,"text":79},{"id":155,"depth":279,"text":156},{"id":203,"depth":279,"text":204},{"id":306,"depth":279,"text":307},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie","1",1000000,"2024-10-03","wiki/2024-10-03-docker-jiao-cheng","en-us:2024-10-03-docker-jiao-cheng","/en-us/wiki/2024-10-03-docker-jiao-cheng","Docker教程","md","wiki/2024-10-03-Docker教程/ch1-简介",false,true,null,"en-US","en-us",{},{"title":5,"description":323},"/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie","_i18n/en-us/wiki/2024-10-03-Docker教程/ch1-简介",1,"wgp6Pn2UHTIQkybrols7D2ZfUeIj1PpHMAHQnKd7JVw",[353,354,360,366,372,378,384,390,396,402,408,414],{"path":331,"stem":349,"title":5,"date":334,"chapter":332,"chapterSort":333,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},{"path":355,"stem":356,"title":357,"date":334,"chapter":358,"chapterSort":359,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch10-1-kuai-su-da-kai-zhong-duan","_i18n/en-us/wiki/2024-10-03-Docker教程/ch10-1-快速打开终端","Quickly Open a Terminal in Docker","10.1",10010000,{"path":361,"stem":362,"title":363,"date":334,"chapter":364,"chapterSort":365,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch10-docker-shi-yong-you-hua","_i18n/en-us/wiki/2024-10-03-Docker教程/ch10-Docker使用优化","Docker Usage Optimization","10",10000000,{"path":367,"stem":368,"title":369,"date":334,"chapter":370,"chapterSort":371,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch2-an-zhuang-docker","_i18n/en-us/wiki/2024-10-03-Docker教程/ch2-安装Docker","Install Docker","2",2000000,{"path":373,"stem":374,"title":375,"date":334,"chapter":376,"chapterSort":377,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch3-docker-zhi-tong","_i18n/en-us/wiki/2024-10-03-Docker教程/ch3-Docker直通","Docker Passthrough","3",3000000,{"path":379,"stem":380,"title":381,"date":334,"chapter":382,"chapterSort":383,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch4-dockerhub-huan-yuan","_i18n/en-us/wiki/2024-10-03-Docker教程/ch4-DockerHub换源","DockerHub change source","4",4000000,{"path":385,"stem":386,"title":387,"date":334,"chapter":388,"chapterSort":389,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch5-docker-rong-qi-li-de-cheng-xu-de-tu-xing-jie-mian-tan-bu-chu-lai","_i18n/en-us/wiki/2024-10-03-Docker教程/ch5-docker容器里的程序的图形界面弹不出来","The graphical interface of the program inside the Docker container cannot be displayed.","5",5000000,{"path":391,"stem":392,"title":393,"date":334,"chapter":394,"chapterSort":395,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch6-docker-ming-ling-xue-xi","_i18n/en-us/wiki/2024-10-03-Docker教程/ch6-Docker命令学习","Learning Docker Commands","6",6000000,{"path":397,"stem":398,"title":399,"date":334,"chapter":400,"chapterSort":401,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch7-ge-zhong-docker-rong-qi-bu-shu","_i18n/en-us/wiki/2024-10-03-Docker教程/ch7-各种Docker容器部署","Deploying various Docker containers","7",7000000,{"path":403,"stem":404,"title":405,"date":334,"chapter":406,"chapterSort":407,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch8-shou-dong-chuang-jian-docker-jing-xiang","_i18n/en-us/wiki/2024-10-03-Docker教程/ch8-手动创建Docker镜像","Manually create a Docker image","8",8000000,{"path":409,"stem":410,"title":411,"date":334,"chapter":412,"chapterSort":413,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":341},"/en-us/wiki/2024-10-03-docker-jiao-cheng/ch9-vscode-yuan-cheng-kai-fa","_i18n/en-us/wiki/2024-10-03-Docker教程/ch9-VScode远程开发","VScode remote development","9",9000000,{"path":337,"stem":415,"title":416,"date":334,"chapter":343,"chapterSort":417,"docKey":336,"docRoot":337,"docTitle":338,"isWikiDoc":342,"isWikiIndex":342},"_i18n/en-us/wiki/2024-10-03-Docker教程/index","Docker tutorial",0,{"variants":419},[420,421,424,427,430],{"path":331,"localeSlug":345,"i18nKey":340},{"path":422,"localeSlug":423,"i18nKey":340},"/zh-hant/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie","zh-hant",{"path":425,"localeSlug":426,"i18nKey":340},"/zh-hk/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie","zh-hk",{"path":428,"localeSlug":429,"i18nKey":340},"/zh-tw/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie","zh-tw",{"path":431,"localeSlug":432,"i18nKey":340},"/zh-cn/wiki/2024-10-03-docker-jiao-cheng/ch1-jian-jie","zh-cn",[331,348,422,348,425,348,428,348,431,348],1780671794030]