Bil*_*ant 9 docker visual-studio-code vscode-remote
在“VS Code远程开发”中启动附加容器时,是否有人找到了在启动vscode集成终端时更改容器外壳的方法。
它似乎运行类似的东西。
docker exec -it <containername> /bin/bash
Run Code Online (Sandbox Code Playgroud)
我正在寻找相当于
docker exec -it <containername> /bin/zsh
Run Code Online (Sandbox Code Playgroud)
我发现的附加容器的唯一设置是
"remote.containers.defaultExtensions": []
Run Code Online (Sandbox Code Playgroud)
小智 11
2023 更新 - 在 devcontainer.json 中,设置现在需要嵌套在下面{'customizations': {'vscode': {'settings': {}}}}
例子:
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": { "zsh": { "path": "/bin/zsh" } }
}
}
},
Run Code Online (Sandbox Code Playgroud)
https://containers.dev/supporting
我想为这个线程做出贡献,因为我花了相当多的时间在网络上进行梳理,寻找一个很好的解决方案,涉及 VS Code 的terminal.integrated.profiles.linux 的新 API
请注意,截至 2022 年 1 月 20 日,已注释和未注释的 json 均有效。未注释的行是在开发容器中使用的新的、未弃用的方法。
{
"settings": {
// "terminal.integrated.shell.linux": "/bin/zsh"
"terminal.integrated.defaultProfile.linux": "zsh",
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/bin/zsh"
},
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果有人感兴趣的话,我还想出了如何将 oh my ZSH 内置到图像中。
Dockerfile:
# Setup Stage - set up the ZSH environment for optimal developer experience
FROM node:16-alpine AS setup
RUN npm install -g expo-cli
# Let scripts know we're running in Docker (useful for containerized development)
ENV RUNNING_IN_DOCKER true
# Use the unprivileged `node` user (pre-created by the Node image) for safety (and because it has permission to install modules)
RUN mkdir -p /app \
&& chown -R node:node /app
# Set up ZSH and our preferred terminal environment for containers
RUN apk --no-cache add zsh curl git
# Set up ZSH as the unprivileged user (we just need to start it, it'll initialize our setup itself)
USER node
# set up oh my zsh
RUN cd ~ && wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh && sh install.sh
# initialize ZSH
RUN /bin/zsh ~/.zshrc
# Switch back to root
USER root
Run Code Online (Sandbox Code Playgroud)
我解决了这个问题
RUN echo "if [ -t 1 ]; then" >> /root/.bashrc
RUN echo "exec zsh" >> /root/.bashrc
RUN echo "fi" >> /root/.bashrc
Run Code Online (Sandbox Code Playgroud)
仍然有兴趣知道是否有办法为每个容器设置这个。
| 归档时间: |
|
| 查看次数: |
9982 次 |
| 最近记录: |