// 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.209.6/containers/go
{
"name": "Go",
"dockerComposeFile" : [
"docker-compose.yml",
"docker-compose.dev.yml"
],
"service" : "study-06",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
// "build": {
// "dockerfile": "Dockerfile",
// "args": {
// // Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17
// // Append -bullseye or -buster to pin to an OS version.
// // Use -bullseye variants on local arm64/Apple Silicon.
// "VARIANT": "1-bullseye",
// // Options
// "NODE_VERSION": "lts/*"
// }
// },
// "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go",
"go.goroot": "/usr/local/go"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"golang.Go"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
4. 修改Dockerfile
最后添加 Expose 9090 绑定端口
5. 在容器中打开文件夹
F1 执行 Open Folder in Container,选择 study.06目录,此时vscode会编译并运行镜像,进入镜像中的环境。