vscode 镜像制作

Dockerfill

# 试验,让container具有ssh forwarding能力,失败,ssh登录后不显示界面
FROM haifengat/centos:8.1
RUN yum install -y xorg-x11-xauth xorg-x11-fonts-* xorg-x11-font-utils xorg-x11-fonts-Type1 \
&& sed -i 's/.*X11UseLocalhost.*/X11UseLocalhost no/' /etc/ssh/sshd_config
RUN rpm --import https://packages.microsoft.com/keys/microsoft.asc \
&& echo $'[code]\n\
name=Visual Studio Code\n\
baseurl=https://packages.microsoft.com/yumrepos/vscode\n\
enabled=1\n\
gpgcheck=1\n\
gpgkey=https://packages.microsoft.com/keys/microsoft.asc\
' > /etc/yum.repos.d/vscode.repo \
&&  yum install -y code \
&& yum install -y libX11-xcb

#安装插件
RUN code --user-data-dir ~/.vscode --install-extension ms-python.python \
&& code --user-data-dir ~/.vscode --install-extension njpwerner.autodocstring \
&& code --user-data-dir ~/.vscode --install-extension PKief.material-icon-theme \
&& code --user-data-dir ~/.vscode --install-extension ms-python.anaconda-extension-pack \
&& code --user-data-dir ~/.vscode --install-extension coenraads.bracket-pair-colorizer \
&& code --user-data-dir ~/.vscode --install-extension ms-ceintl.vscode-language-pack-zh-hans \
&& code --user-data-dir ~/.vscode --install-extension donjayamanne.githistory \
&& code --user-data-dir ~/.vscode --install-extension eamodio.gitlens \
&& code --user-data-dir ~/.vscode --install-extension ms-vscode.go \
&& code --user-data-dir ~/.vscode --install-extension spywhere.guides \
&& code --user-data-dir ~/.vscode --install-extension zainchen.json \
&& code --user-data-dir ~/.vscode --install-extension yzhang.markdown-all-in-one \
&& code --user-data-dir ~/.vscode --install-extension zhuangtongfa.material-theme \
&& code --user-data-dir ~/.vscode --install-extension ms-vscode-remote.remote-ssh \
&& code --user-data-dir ~/.vscode --install-extension ms-vscode-remote.remote-ssh-edit \
&& code --user-data-dir ~/.vscode --install-extension redhat.vscode-yaml \
&& code --user-data-dir ~/.vscode --install-extension ms-vscode.cpptools \
&& code --user-data-dir ~/.vscode --install-extension austin.code-gnu-global

#中文支持
RUN yum install -y langpacks-zh_CN.noarch
ENV LANG=zh_CN.UTF-8 LC_ALL=zh_CN.UTF-8
COPY msyh*.ttc /usr/share/fonts/
RUN mkdir -p /usr/share/fonts/truetype/ && cd /usr/share/fonts/truetype/ \
&& git clone https://github.com/abertsch/Menlo-for-Powerline.git \
&& fc-cache -f -v

#很关键,一直不成功显示就是她的问题
ENV DISPLAY=:10.0
#Vscode配置
ENV USERDATA=/root/.vscode
RUN echo "export VSCODE=\"code --user-data-dir /root/.vscode\"" >> ~/.bashrc

##使用配置
COPY settings.json $USERDATA/User/settings.json
COPY keybindings.json $USERDATA/User/keybindings.json

#setting.json中增加
#"terminal.integrated.shell.linux": "/bin/bash",

ENTRYPOINT ["/usr/sbin/init"]

Build

docker build -t haifengat/vscode:0.0.2 .

Run

docker run -itd --privileged --name code002 --net=host  -v $HOME/.Xauthority:/root/.Xauthority haifengat/vscode:0.0.2
docker exec -it code002 /bin/bash
#### code in container
>>fc-cache -f -v
>>$VSCODE

Save

docker save haifengat/vscode:0.0.2 | gzip > vscode002.tar.gz

测试ssh

docker run -itd --privileged --name vscode002 -p 2222:22 haifengat/vscode:0.0.2
SSH 

你可能感兴趣的:(docker)