结核阳性是什么意思| 情是什么意思| 人养玉三年玉养人一生是什么意思| 肺结核通过什么途径传染| 舌根发黑是什么原因| 初心是什么意思| 东北有什么好玩的景点| 庚子是什么时辰| 什么植物最好养| 柿子什么时候成熟| 18K金什么意思| 触感是什么意思| 干咳吃什么药止咳效果好| 女性肾虚是什么原因导致的| 上善若水下一句是什么| 国防部长有什么权利| 便秘挂什么科| 排骨炖什么菜好吃| 人血白蛋白适合什么人| 为什么插几下就射了| 拔胡子有什么危害| 得了咽炎有什么症状| 祖庭是什么意思| 月经不规律是什么原因| 呛是什么意思| nothomme什么牌子| 蔓越莓有什么功效和作用| 比翼双飞是什么意思| 外阴病变有什么症状| 甲状腺囊肿不能吃什么| 属羊是什么星座| 口苦吃什么好得快| 梦见盖房子什么意思| 扁平疣吃什么药| 斑鸠吃什么| 乌纱帽是什么意思| 西瓜不可以和什么同食| fsw是什么意思| 你有什么| 巴旦木和杏仁有什么区别| 胃痛按什么部位可以缓解疼痛| 移植后屁多是什么原因| 阴虚火旺吃什么调理| 两侧肋骨疼是什么原因| 拉肚子吃什么消炎药好| 活性酶是什么| 孕妇吃葡萄对胎儿有什么好处| 什么满天下| 什么工作挣钱多| 银装素裹是什么意思| 怀孕什么时候能测出来| 刚怀孕要吃些什么好| 孜孜不倦什么意思| 尿路感染吃什么药好| 今年52岁属什么生肖| 教授相当于什么级别| 福建为什么叫八闽| 骨质疏松吃什么好| 检查糖尿病挂什么科| 什么情况下需要做喉镜检查| 红茶加枸杞有什么功效| 拉屎拉出血是什么原因| 儿童调理脾胃用什么药最好| 白内障用什么眼药水| 皮角是什么病| 26岁属什么| 排卵期为什么会出血| 荡秋千有什么好处| 零八年属什么生肖| 看包皮挂什么科| 反射弧太长是什么意思| 办慢性病有什么好处| 幼儿园学什么| 陈皮是什么皮| 林伽是什么| 什么动物睡觉不闭眼| 痰湿中阻吃什么中成药| 鼻窦炎是什么原因引起的呢| 区块链技术是什么| 黑脸娃娃有什么功效| 纸可以折什么| 利字五行属什么| 虐猫是什么意思| 拔智齿后吃什么消炎药| 子宫内膜回声欠均匀什么意思| 为什么肾阳虚很难恢复| 端午节在什么时候| 上午12点是什么时候| 头疼是为什么| 爷爷的妈妈叫什么| 外婆菜是什么| pu是什么元素| 为什么的拼音怎么写| 女性什么时候最容易怀孕| 新生儿贫血是什么原因造成的| 女真族现在是什么族| 老年人腿浮肿是什么原因引起的| 坦诚相待是什么意思| 什么的琴声| 过敏性结膜炎用什么药| 吃什么子宫肌瘤会消除| 唐僧的袈裟叫什么| 人间蒸发是什么意思| 坐骨神经痛用什么药| 梦见大领导有什么预兆| 梦见穿新衣服是什么意思| 喝罗汉果水有什么功效| 十二朵玫瑰花代表什么意思| 京东发什么快递| 11.9是什么星座| 银芽是什么菜| 手持吸尘器什么牌子好| 回流什么意思| 78年属马的是什么命| 1964属什么生肖| 炖排骨什么时候放盐| 孤僻的人给人什么感觉| 装牙套有什么坏处| 心什么气什么| 什么叫做基本工资| 防疫站属于什么单位| 水军什么意思| 为什么会得口腔溃疡| 运动减肥为什么体重不减反增| 丁香花长什么样| 6月9日是什么星座| 阿拉伯人属于什么人种| 长孙是什么意思| 梦见孩子拉粑粑是什么意思| 两性是什么意思| 中国的国宝是什么| 长辈生日送什么好| 糖尿病可以吃什么肉| 什么情况下能吃脑络通| 尽兴是什么意思| 女人梦到地震预示什么| 3月21号是什么星座| 看见乌鸦有什么预兆| 什么是情人| rarone是什么牌子的手表| 甲状腺tsh高说明什么| S是什么牌子鞋| 卡介苗是预防什么的| 生鱼又叫什么鱼| 一什么圆月| 口干咽干是什么原因| 贫血喝什么口服液最好| 心肌缺血做什么检查能查出来| 梦见吃西瓜是什么征兆| 子宫肌瘤吃什么食物好| 一个田一个比读什么| 阳痿早泄吃什么药| 抑郁气滞是什么症状| 喝什么补气血| cpap是什么意思| 有什么好听的网名| 清洁度三度什么意思| 烟酸是什么| 五月十九日是什么星座| 颈椎酸胀是什么原因| 传媒公司主要做什么| 虾仁炒什么好吃又简单| 湖北九头鸟是什么意思| 轻度抑郁有什么症状| 化缘是什么意思| 阳历7月份是什么星座| 鲛人是什么意思| 我低头向山沟是什么歌| 胎儿脉络丛囊肿是什么原因引起的| 旅长是什么级别| 冲任失调是什么意思| 梦见老公回来了是什么征兆| 女性支原体阳性是什么意思| 51岁属什么生肖| 梦见自己儿子死了是什么意思| 手上蜕皮是什么原因| 第一次怀孕有什么反应| 陕西什么面| 艾灸能治什么| 低密度脂蛋白是什么| 黑乌龙茶属于什么茶| 风致是什么意思| 碧螺春是什么茶| 梦见死去的朋友是什么意思| 人格独立是什么意思| 喝芝麻糊有什么好处| 得了肠息肉有什么症状| 猫眼石是什么| 985是什么学校| 燕窝有什么营养价值| 做梦翻车了什么预兆| 上睑下垂是什么原因造成的| 下葬下雨是什么兆头| 高数是什么| opi是什么意思| 2018是什么生肖| 庚日是什么意思啊| 木牛流马是什么意思| 喝劲酒有什么好处| 祭是什么意思| 黑豆不能和什么一起吃| 云服务是什么| 优思悦是什么药| 区法院院长是什么级别| 坚字五行属什么| 7月去青海带什么衣服| 火龙果不能和什么一起吃| 头出汗多至头发湿透是什么原因| 女生吃避孕药有什么副作用| 手麻看什么科| 什么是日记| 三醋酯纤维是什么面料| 安道尔微信暗示什么| 阿斯巴甜是什么| 什么是几何图形| 口苦吃什么中药| 执行标准是什么意思| 痛风吃什么蔬菜好| 川字纹有什么影响| 五台山求什么最灵| 乐不思蜀什么意思| 两极分化是什么意思| 低钠有什么症状和危害| 荷花和睡莲有什么区别| 胃酸烧心吃什么食物| 中暑什么症状| 十月二十三号是什么星座| 朱砂属于五行属什么| 六字真言是什么| 一什么一笑| 双眼屈光不正是什么意思| 胃泌素高是什么原因| 孕妇地中海贫血对胎儿有什么影响| 生物指的是什么| 过敏用什么药膏| 诸事顺遂是什么意思| 皮肤暗黄是什么原因造成的| 边长是什么| 茶油有什么功效| 光谱是什么| 荔枝吃了有什么好处| 牛头不对马嘴是什么意思| 居居是什么意思| 莲子是什么| 杭州什么宽带好又便宜| 扁平苔藓是什么原因引起的| 做什么来钱快| 甘草不能和什么一起吃| 口若悬河是指什么生肖| 天下乌鸦一般黑是什么生肖| 妇科炎症用什么药最好| 下丘脑分泌什么激素| 身上起疙瘩是什么原因| 许冠杰属什么生肖| 酷暑难当是什么意思| sd是什么| 电荷是什么意思| 总胆固醇高忌口什么| 梦见蜂蜜是什么意思| 新生儿什么时候剪头发| 海参是补什么的| 晶体是什么| 美丽的动物是什么生肖| 胰腺不好吃什么食物好| 百度

Try to extend agent mode in VS Code!

深圳湾科技生态园四区公共部位精装修工程招标公告

百度 在科尼亚旋转,感受人与神的触碰,飞舞跳跃到卡帕多奇亚。

Docker Compose provides a way to orchestrate multiple containers that work together. Examples include a service that processes requests and a front-end web site, or a service that uses a supporting function such as a Redis cache. If you are using the microservices model for your app development, you can use Docker Compose to factor the app code into several independently running services that communicate using web requests. This article helps you enable Docker Compose for your apps, whether they are Node.js, Python, or .NET, and also helps you configure debugging in Visual Studio Code for these scenarios.

Also, for single-container scenarios, using Docker Compose provides tool-independent configuration in a way that a single Dockerfile does not. Configuration settings such as volume mounts for the container, port mappings, and environment variables can be declared in the docker-compose YML files.

To use Docker Compose in VS Code using the Container Tools extension, you should already be familiar with the basics of Docker Compose.

Adding Docker Compose support to your project

If you already have one or more Dockerfiles, you can add Docker Compose files by opening the Command Palette (??P (Windows, Linux Ctrl+Shift+P)), and using the Containers: Add Docker Compose Files to Workspace command. Follow the prompts.

You can add Docker Compose files to your workspace at the same time you add a Dockerfile by opening the Command Palette (??P (Windows, Linux Ctrl+Shift+P)) and using the Containers: Add Docker Files to Workspace command. You'll be asked if you want to add Docker Compose files. If you want to keep your existing Dockerfile, choose No when prompted to overwrite the Dockerfile.

The Container Tools extension adds the docker-compose.yml file to your workspace. This file contains the configuration to bring up the containers as expected in production. In some cases, a docker-compose.debug.yml is also generated. This file provides a simplified mode for starting that enables the debugger.

Screenshot of project with docker-compose files

The VS Code Container Tools extension generates files that work out of the box, but you can also customize them to optimize for your scenario. You can then use the Containers: Compose Up command (right-click on the docker-compose.yml file, or find the command in the Command Palette) to get everything started at once. You can also use the docker-compose up command from the command prompt or terminal window in VS Code to start the containers. Refer to the Docker Compose documentation about how to configure the Docker Compose behavior and what command-line options are available.

With the docker-compose files, you can now specify port mappings in the docker-compose files, rather than in the .json configuration files. For examples, see the Docker Compose documentation.

Tip: When using Docker Compose, don't specify a host port. Instead, let the Docker pick a random available port to automatically avoid port conflict issues.

Add new containers to your projects

If you want to add another app or service, you can run Containers: Add Docker Compose Files to Workspace again, and choose to overwrite the existing docker-compose files, but you'll lose any customization in those files. If you want to preserve changes to the compose files, you can manually modify the docker-compose.yml file to add the new service. Typically, you can copy the existing service section, paste it to create a new entry, and change the names as appropriate for the new service.

You can run the Containers: Add Docker Files to Workspace command again to generate the Dockerfile for a new app. While each app or service has its own Dockerfile, there's typically one docker-compose.yml and one docker-compose.debug.yml file per workspace.

In Python projects, you have the Dockerfile, .dockerignore, docker-compose*.yml files all in the root folder of the workspace. When you add another app or service, move the Dockerfile into the app's folder.

In Node.js projects, the Dockerfile and .dockerignore files will be next to the package.json for that service.

For .NET, the folder structure is already set up to handle multiple projects when you create the Docker Compose files, .dockerignore and docker-compose*.yml are placed in the workspace root (for example, if the project is in src/project1, then the files are in src), so when you add another service, you create another project in a folder, say project2, and recreate or modify the docker-compose files as described previously.

Debug

First, refer to the debugging documentation for your target platform, to understand the basics on debugging in containers with VS Code:

If you want to debug in Docker Compose, run the command Containers: Compose Up using one of the two Docker Compose files as described in the previous section, and then attach using the appropriate Attach launch configuration. Launching directly using the normal launch configuration does not use Docker Compose.

Create an Attach launch configuration. This is a section in launch.json. The process is mostly manual, but in some cases, the Container Tools extension can help by adding a pre-configured launch configuration that you can use as a template and customize. The process for each platform (Node.js, Python, and .NET) is described in the following sections.

Node.js

  1. On the Debug tab, choose the Configuration dropdown, choose New Configuration and select the Containers: Attach configuration template Containers: Attach to Node.

  2. Configure the debugging port in docker-compose.debug.yml. This is set when you create the file, so you might not need to change it. In the example below, port 9229 is used for debugging on both the host and the container.

     version: '3.4'
    
     services:
       node-hello:
         image: node-hello
         build: .
         environment:
           NODE_ENV: development
         ports:
           - 3000
           - 9229:9229
         command: node --inspect=0.0.0.0:9229 ./bin/www
    
  3. If you have multiple apps, you need to change the port for some of them, so that each app has a unique port. You can point to the right debugging port in the launch.json, and save the file. If you omit this, the port will be chosen automatically.

    Here's an example that shows the Node.js launch configuration - Attach:

     "configurations": [
         {
             "type": "node",
             "request": "attach",
             "name": "Containers: Attach to Node",
             "remoteRoot": "/usr/src/app",
             "port": 9229 // Optional; otherwise inferred from the docker-compose.debug.yml.
         },
         // ...
     ]
    
  4. When done editing the Attach configuration, save launch.json, and select your new launch configuration as the active configuration. In the Debug tab, find the new configuration in the Configuration dropdown.

    Screenshot of Configuration dropdown

  5. Right-click on the docker-compose.debug.yml file and choose Compose Up.

  6. When you attach to a service that exposes an HTTP endpoint that returns HTML, the web browser doesn't open automatically. To open the app in the browser, choose the container in the sidebar, right-click and choose Open in Browser. If multiple ports are configured, you'll be asked to choose the port.

  7. Launch the debugger in the usual way. From the Debug tab, choose the green arrow (Start button) or use F5.

Python

For debugging Python with Docker Compose, follow these steps:

  1. On the Debug tab, choose the Configuration dropdown, choose New Configuration, choose Python Debugger, and select the Remote Attach configuration template.

    Screenshot of Python Remote Attach

  2. You're prompted to choose the host machine (for example, localhost) and port you want to use for debugging. The default debugging port for Python is 5678. If you have multiple apps, you need to change the port for one of them, so that each app has a unique port. You can point to the right debugging port in the launch.json, and save the file. If you omit this, the port will be chosen automatically.

         "configurations": [
         {
            "name": "Python Debugger: Remote Attach",
            "type": "debugpy",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/app"
                }
            ]
        }
    
  3. When done editing the Attach configuration, save the launch.json. Navigate to the Debug tab, and select Python Debugger: Remote Attach as the active configuration.

  4. If you already have a valid Dockerfile, we recommend running the command Containers: Add Docker Compose Files to Workspace. This will create a docker-compose.yml file and also a docker-compose.debug.yml, which volume maps and starts the Python debugger in the container. If you do not have a Dockerfile already, we recommend running Containers: Add Docker Files to Workspace and selecting Yes to include Docker Compose files.

    Note: By default, when using Containers: Add Docker Files to Workspace, choosing the Django and Flask options will scaffold a Dockerfile configured for Gunicorn. Follow the instructions in the Python in a container quickstart to ensure it is configured properly before proceeding.

  5. Right-click on the docker-compose.debug.yml file (example shown below) and choose Compose Up.

    version: '3.4'
    
    services:
      pythonsamplevscodedjangotutorial:
        image: pythonsamplevscodedjangotutorial
        build:
          context: .
          dockerfile: ./Dockerfile
        command: ["sh", "-c", "pip install debugpy -t /tmp && python /tmp/debugpy --wait-for-client --listen 0.0.0.0:5678 manage.py runserver 0.0.0.0:8000 --nothreading --noreload"]
        ports:
          - 8000:8000
          - 5678:5678
    
  6. Once your container is built and running, attach the debugger by hitting F5 with the Python Debugger: Remote Attach launch configuration selected.

    Screenshot of debugging in Python

    Note: If you would like to import the Python debugger into a specific file, more information can be found in the debugpy README.

  7. When you attach to a service that exposes an HTTP endpoint and returns HTML, the web browser may not open automatically. To open the app in the browser, right-click the container in the Container Explorer and choose Open in Browser. If multiple ports are configured, you'll be asked to choose the port.

    Screenshot - Open in Browser

    You're now debugging your running app in the container.

.NET

  1. On the Debug tab, choose the Configuration dropdown, choose New Configuration and select the Container Attach configuration template Containers: .NET Attach (Preview).

  2. VS Code tries to copy vsdbg from the host machine to the target container using a default path. You can also provide a path to an existing instance of vsdbg in the Attach configuration.

     "netCore": {
         "debuggerPath": "/remote_debugger/vsdbg"
     }
    
  3. When done editing the Attach configuration, save launch.json, and select your new launch configuration as the active configuration. In the Debug tab, find the new configuration in the Configuration dropdown.

  4. Right-click on the docker-compose.debug.yml file and choose Compose Up.

  5. When you attach to a service that exposes an HTTP endpoint that returns HTML, the web browser doesn't open automatically. To open the app in the browser, choose the container in the sidebar, right-click and choose Open in Browser. If multiple ports are configured, you'll be asked to choose the port.

  6. Launch the debugger in the usual way. From the Debug tab, choose the green arrow (Start button) or use F5.

    Screenshot of starting debugging

  7. If you try to attach to a .NET app running in a container, you'll see a prompt ask to select your app's container.

    Screenshot of container selection

    To skip this step, specify the container name in the Attach configuration in launch.json:

        "containerName": "Your ContainerName"
    

    Next, you're asked if you want to copy the debugger (vsdbg) into the container. Choose Yes.

    Screenshot of debugger prompt

If everything is configured correctly, the debugger should be attached to your .NET app.

Screenshot of debug session

Volume mounts

By default, the Container Tools extension does not do any volume mounting for debugging components. There's no need for it in .NET or Node.js, since the required components are built into the runtime. If your app requires volume mounts, specify them by using the volumes tag in the docker-compose*.yml files.

volumes:
    - /host-folder-path:/container-folder-path

Docker Compose with multiple Compose files

Workspaces can have multiple docker-compose files to handle different environments like development, test, and production. The content of the configuration can be split into multiple files. For example, a base compose file that defines the common information for all environments and separate override files that define environment-specific information. When these files are passed as input to the docker-compose command, it combines these files into a single configuration. By default, the Containers: Compose Up command passes a single file as input to the compose command, but you can customize the compose up command to pass in multiple files using command customization. Or, you can use a custom task to invoke the docker-compose command with the desired parameters.

Note: If your workspace has docker-compose.yml and docker-compose.override.yml and no other compose files, then the docker-compose command is invoked with no input files and it implicitly uses these files. In this case, no customization is needed.

Command customization

Command customization provides various ways to customize the compose up command based on your requirements. The following are few sample command customization for the compose up command.

Base file and an override file

Let's assume your workspace has a base compose file (docker-compose.yml) and an override file for each environment (docker-compose.dev.yml, docker-compose.test.yml and docker-compose.prod.yml) and you always run docker compose up with the base file and an override file. In this case, the compose up command can be customized as in the following example. When the compose up command is invoked, the ${configurationFile} is replaced by the selected file.

"docker.commands.composeUp": [
    {
        "label": "override",
        "template": "docker-compose -f docker-compose.yml ${configurationFile}  up -d --build",
    }
]

Template matching

Let's assume you have a different set of input files for each environment. You could define multiple templates with regular expression match, and the selected file name will be matched against this match property and the corresponding template will be used.

"containers.commands.composeUp": [
    {
        "label": "dev-match",
        "template": "docker-compose -f docker-compose.yml -f docker-compose.debug.yml -f docker-compose.dev.yml up -d --build",
        "match": "dev"
    },
    {
        "label": "test-match",
        "template": "docker-compose -f docker-compose.yml -f docker-compose.debug.yml -f docker-compose.test.yml up -d --build",
        "match": "test"
    },
    {
        "label": "prod-match",
        "template": "docker-compose -f docker-compose.yml -f docker-compose.release.yml -f docker-compose.prod.yml up -d --build",
        "match": "prod"
    }
]

Pick a template when the command is invoked

If you omit the match property from command templates, you're asked which template to use each time compose up command is invoked. For example:

"containers.commands.composeUp": [
    {
        "label": "dev",
        "template": "docker-compose -f docker-compose.yml -f docker-compose.common.dev.yml ${configurationFile} up -d --build"
    },
    {
        "label": "test",
        "template": "docker-compose -f docker-compose.yml -f docker-compose.common.test.yml ${configurationFile} up -d --build"
    },
    {
        "label": "prod",
        "template": "docker-compose -f docker-compose.yml -f docker-compose.common.prod.yml ${configurationFile} up -d --build"
    },
],

Custom tasks

Rather than use command customization, you can also define a task like the following to invoke a docker-compose command. Please refer custom task for more detail on this option.

{
  "type": "shell",
  "label": "compose-up-dev",
  "command": "docker-compose -f docker-compose.yml -f docker-compose.Common.yml -f docker-compose.dev.yml up -d --build",
  "presentation": {
    "reveal": "always",
    "panel": "new"
  }
}

Next steps

蜗牛吃什么 什么是调剂 脸颊红是什么原因 右手手指头麻木是什么病的前兆 骨蒸潮热是什么症状
反响是什么意思 胃ct能检查出什么病 次日什么意思 仲夏夜是什么意思 wht什么颜色
格局是什么 什么叫细胞 八格牙路是什么意思 乖巧是什么意思 7.15什么星座
万寿菊什么时候开花 厉兵秣马什么意思 餐后血糖高是什么原因 醛固酮高吃什么降压药 2月27是什么星座
龟兔赛跑的故事告诉我们什么道理hcv8jop4ns0r.cn 用什么洗脸可以祛斑hcv7jop9ns1r.cn 同归于尽是什么意思hcv9jop7ns9r.cn 月经咖啡色是什么原因hcv8jop6ns7r.cn 什么是原发性高血压和继发性高血压hcv8jop7ns9r.cn
吃天麻对身体有什么好处hcv8jop4ns0r.cn 瘢痕子宫是什么意思hcv7jop7ns4r.cn 正比是什么意思hcv8jop7ns8r.cn 什么器晚成hcv8jop7ns8r.cn 中性粒细胞百分比偏低是什么意思hcv8jop2ns1r.cn
玉和玉髓有什么区别zsyouku.com 牙疼可以吃什么hcv8jop7ns1r.cn 点了痣要注意什么hcv8jop3ns7r.cn 脚心疼什么原因luyiluode.com 脑膜炎有什么症状hcv9jop2ns7r.cn
低压高是什么引起的hcv8jop9ns1r.cn 为什么会胰岛素抵抗hcv8jop9ns9r.cn 吃蝎子有什么好处luyiluode.com 什么的假山hcv8jop9ns4r.cn 海参什么人不能吃hcv9jop3ns5r.cn
百度