简体   繁体   English

vscode-remote-container 在 post*Command 后打开用户终端

[英]vscode-remote-container open user terminal after post*Command

if you run a post*Command you get an integrated terminal that runs the command(s) and outputs:如果您运行post*Command ,您将获得一个运行命令和输出的集成终端:

Running the PostCreateCommand from devcontainer.json...从 devcontainer.json 运行 PostCreateCommand...

[2709 ms] Start: Run in container: ... [2709 毫秒] 开始:在容器中运行:...

Done.完毕。 Press any key to close the terminal.按任意键关闭终端。

is there a way to have this auto close and open a user terminal or just leave it and open a user terminal as if you werent running any commands from devcontainer.json at all?有没有办法让这个自动关闭并打开一个用户终端,或者只是离开它并打开一个用户终端,就好像你根本没有运行来自devcontainer.json的任何命令一样?

Using an example involving Python, you can try using postAttachCommand :使用涉及 Python 的示例,您可以尝试使用postAttachCommand

{
    "postCreateCommand": ["poetry", "install"],
    "postAttachCommand": "bash"
}

which gives:这使:

Running the postCreateCommand from devcontainer.json...

[28000 ms] Start: Run in container: poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: project (0.1.0)

Running the postAttachCommand from devcontainer.json...

[33815 ms] Start: Run in container: /bin/sh -c bash
root@a0fd27a3b2cc:/workspaces/directory#

The description for postCreateCommand reads: postCreateCommand的描述如下:

A command to run after creating the container.创建容器后要运行的命令。 This command is run after "updateContentCommand" and before "postStartCommand" .此命令在 "updateContentCommand" 之后和"postStartCommand" 之前运行。

whereas the description for postAttachCommand specifies:postAttachCommand的描述指定:

A command to run when attaching to the container.附加到容器时运行的命令。 This command is run after "postStartCommand".此命令在“postStartCommand”之后运行。

So other variations might be possible, but this one worked for me.所以其他变化可能是可能的,但这个对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 附加到现有远程容器时如何使VSCode终端以非root用户身份登录 - How to make VSCode terminal log in as a non-root user when attaching to an existing remote container VSCode 远程容器 — 如何打开 VSCode 的容器实例中的默认文件夹? - VSCode Remote Container — how to open the default folder in the container instance of VSCode? 如何在设置正确的用户时将 VSCode 附加到远程 Docker 容器 - How to attach VSCode to a remote Docker container while setting the correct user 如何使用 VSCode 的远程开发扩展在容器外的 Docker 容器中打开文件 - How to open files in a Docker container outside of container using the Remote Development extension for VSCode 在mongo容器外壳中键入某些命令后,终端卡住 - terminal gets stuck after typing some command in the mongo container shell 使用 vscode 在 docker 容器中打开一个文件 - open a file in docker container with vscode 在 VSCode 中连接到远程 docker 容器的依赖项? - Dependencies to connect to a remote docker container in VSCode? 防止 VSCode 远程容器中的 GPG 密钥共享 - Prevent GPG key sharing in VSCode Remote Container VSCode 远程容器默认 python 解释器 - VSCode remote-container default python interpreter VSCode Remote - 添加到现有 - 破坏容器 - VSCode Remote - Add to Existing - Breaks Container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM