问题标签 [vscode-devcontainer]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
33 浏览

docker - How to transition VSCode devcontainers to a production environment?

I'm a bit of a newb so bear with me. I'm familiar with writing local applications and scripts to automate admin tasks that I need to do, but now I'm trying to get familiar with the Gitlab CI/CD process. I have been using (and loving) VSCode devcontainers because I fell into a hole of learning Python virtual environments and trying to manage different python versions, etc., and devcontainers makes all that headache go away for me. Now I'm trying to figure out how I can write a simple application (like a flask endpoint) and deploy it via Gitlab CI/CD.

I'm currently stuck on how to transition my VSCode Dockerfile for the devcontainer to a production ready Dockerfile. For instance, the VSCode Dockerfile uses a VSCode base image that I wouldn't imagine would be acceptable in a production environment. Is there a best practice for creating a production Docker configuration for deployments? If it is simply a matter of creating a separate Dockerfile, doesn't that defeat one of the purposes of using Docker containers for development? You would still have a situation of "well it works in my container..."

0 投票
0 回答
35 浏览

mongodb - 无法从 devcontainer 连接到数据库

我正在为教育环境构建环境,但由于某种原因,我的开发容器无法连接到由docker-compose.yml. 见下文:

当我尝试使用本地主机上的端口 5432 上的 SQLTools 连接到 PostgreSQL 数据库时,我得到以下信息:

作为一个可能重要的方面,我还注意到 PostgreSQL 实例不断重新启动。这是 docker 容器集的样子:

在此处输入图像描述

但是,我应该注意,我也无法使用 Mongo for VS Code 扩展连接到 mongodb 实例。

让我知道我怎样才能完成这项工作!

0 投票
0 回答
53 浏览

docker - VS Code devcontainer - Dockerfile中的containerUser和USER有什么区别?

文档

containerUser: Overrides the user for all operations run as inside the container. Defaults to either root or the last USER instruction in the related Dockerfile used to create the image.

是不是意味着当你在containerUser下面设置

USER和下面一样Dockerfile??

0 投票
1 回答
21 浏览

visual-studio-code - 在开发容器中安装主机卷

我创建了一个带有一些自定义依赖项编译的开发容器。经过几个小时的构建,是时候运行我的第一个测试了。我的测试需要将主机磁盘上的文件(预训练模型和一些数据)加载到单独的文件夹中。使用 docker compose 或 docker 命令行等工具运行,我可以通过指定卷与容器共享主机文件。开发容器对代码文件夹执行相同的操作,但是如何为开发容器指定额外的卷。

0 投票
0 回答
12 浏览

python - Devcontainers -> 无法导入 pip 安装的库

Python。

我目前正在使用 devcontainers,但无法在其中安装和使用库。我有一个 Piplock 文件,用于在创建 devcontainer 时安装依赖项,但是一旦使用它,我就无法安装新库

0 投票
0 回答
14 浏览

docker - Vscode Devcontainer - Docker-from-Docker 设置无法访问具有转发端口的其他容器

我正在按照文档中的说明进行 docker-from-docker 设置,但没有在 devcontainer 中转发端口。

该项目是一个 nodejs,我想使用我的 verdaccio 作为我的注册表。

在 devcontainer 中需要做什么才能访问其他已暴露和转发端口的 docker 容器?

0 投票
0 回答
22 浏览

typescript - webpack 只看入口文件

我有一个项目,我希望 webpack 和 devserver 热重新加载我的更改并在我在项目中保存文件后立即刷新我的浏览器。

但是,这一切都适用于我的入口文件(main.ts)。但是对于位于 and 的文件夹和子文件夹中的其余代码./game./uiWebpack 无法检测到文件更改(我认为它甚至不会打扰观看)。

我错过了什么吗?

这里是my webpack.config.js。仅供参考,该项目使用 TypeScript 和开发容器。

有任何想法吗?

0 投票
1 回答
71 浏览

git - 在 VSCode Dev Container (WSL2 Ubuntu v20) 中集成 GPG 签名的 Git 提交

我正在WSL2使用Ubuntu v20带有VSCode.

我想将 GPG 签名的 Git Commit 发送到GitHubVSCode Dev Container

我尝试使用如下设置:

  1. 在 Windows 中安装Gpg4win

  2. 将软件包安装在WSL2

  1. 编辑~/.gnupg/gpg-agent.conf如下WSL2
  1. 杀死代理
  1. 生成密钥WSL2
  1. 列出其中的键WSL2

示例输出

  1. set git config in WSL2,email 与 GPG 密钥匹配。
  1. 导出密钥并导入Github.
  1. 当我使用下面的 CLI 提交代码时WSL2,会弹出一个让我输入密码的弹出窗口,我可以成功提交代码。

但是,我无法提交Dev Container instance以下错误中的代码:

如何提交代码Dev Container instance?谢谢

0 投票
0 回答
18 浏览

docker - 无法将 env 文件与 vscode devcontainer 一起使用:没有这样的文件或目录

我按照这个简短的官方视频尝试在我的文件中使用环境devcontainer.json文件。我的文件夹架构与视频相同,我devcontainer.json看起来像:

但我不断收到此错误: docker: open .devcontainer/devcontainer.env: no such file or directory.当我运行rebuild containeror时rebuild container without cache

但该文件确实存在。ls .devcontainer/devcontainer.env我可以通过在我的恢复容器中运行来验证它。

我什至对devcontainer.env文件进行了版本控制并Clone Repository in container volume再次运行。还是同样的错误。

知道发生了什么吗?

0 投票
0 回答
12 浏览

python - 将卷上传到存储库的最佳方法

我正在使用PythonFlaskDocker image. 在使用Remote-Containers来自VS Code(在 Windows 中,安装了 Docker 桌面)的功能进行开发时。

此 API 使用在我的电脑中本地创建的卷。当 VSCode 打开容器时,我连接了卷。我的.devcontainer.json

我的dockerfile(以防万一)

我是这种开发的新手,官方文档可能有点压倒性,所以我有几个问题:

  • 我想将此上传到存储库,但我不知道如何上传该卷。有没有办法创建(如果不存在)卷?这是在开发新人并且没有创建卷(直到我们有一个远程卷)的想法。我想要的是,通过一个简单的 git clone,如果可能的话,能够拥有完整的开发环境。
  • 我是否使用“最佳”方式将音量连接到我的音量devcontainer?阅读了很多问题,这个问题对我有用,但我不知道其中的含义。
  • 利用这个问题,有没有更好的方法来做到这一点?我遵循了很多教程,我的项目是一些教程的混合。
  • 我应该从 更改DockerfileDocker-compose吗?似乎 withdocker-compose更容易。

对不起,如果问题有点奇怪,但我对这一切都很陌生,我不知道我是否走在正确的道路上。提前致谢!