代码之家  ›  专栏  ›  技术社区  ›  Hebert Lima

使用Dev容器在网络(LAN)上运行vue应用程序

  •  0
  • Hebert Lima  · 技术社区  · 2 年前

    //devcontainer.json
    // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
    // https://github.com/microsoft/vscode-dev-containers/tree/v0.238.0/containers/javascript-node
    {
        "name": "node",
        "build": {
            "dockerfile": "Dockerfile",
            "args": { "VARIANT": "18-bullseye", "network": "host" }
        },
    
        "customizations": {
            "vscode": {
                "extensions": [
                    "dbaeumer.vscode-eslint",
                    "dbaeumer.vscode-eslint",
                    "anseki.vscode-color",
                    "GitHub.copilot",
                    "sainoba.px-to-rem",
                    "bradlc.vscode-tailwindcss",
                    "neptunedesign.vs-sequential-number",
                    "Wscats.vue"
                ]
            }
        },
    
        "settings": {
            "remote.localPortHost": "allInterfaces"
        },
    
        "forwardPorts": [8080],
    
        "remoteUser": "node"
    }
    
    # DockerFile
    ARG VARIANT=16-bullseye
    FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
    
    EXPOSE 8080
    

    我还尝试在每个本地环境的设置中添加设置: enter image description here

    远程: enter image description here

    即使在工作区。。。 enter image description here

    enter image description here

    我需要修复移动版本中的一些问题,如果能够通过wi-fi直接访问它就好了,提前谢谢

    Mac OS 12.4
    Docker Desktop 4.9.1(81317)

    enter image description here

    0 回复  |  直到 2 年前
        1
  •  1
  •   ric    2 年前

    // "forwardPorts": [8080],
    

    并添加:

    "appPort": [8080, "192.168.0.10:8080:8080"],
    
    • 第一个8080使您的主机(也称为您的Mac)能够使用localhost:8080或127.0.0.1:8080访问远程容器

    必须重建

    http://192.168.0.10:8080

    在某种程度上,我们试图配置一个使用vscode创建的远程容器,并从LAN进行连接。看见 devcontainerjson-reference containers#_publishing-a-port

        2
  •  1
  •   Gabe    2 年前

    See docker docs

    希望这有帮助。