docker: 如何设置tightvncserver密码?

docker: how to set tightvncserver password?

在我的 Dockerfile 结束时,基于 ubuntu:latest 我正在准备所有我认为我需要 运行 tightvncserver 超过 xfce4

我配置了启动脚本并设置了密码

COPY vncserver /etc/init.d/vncserver
COPY vncservers.conf /etc/vncserver/vncservers.conf

RUN mkdir -p "$HOME/.vnc" && chmod go-rwx "$HOME/.vnc" ; \
    /bin/bash -c "vncpasswd -f <<< mypwd > $HOME/.vnc/passwd"; \
    echo "#!/bin/bash" >  ~/.vnc/xstartup; \
    echo "unset SESSION_MANAGER" >>  ~/.vnc/xstartup; \
    echo "unset DBUS_SESSION_BUS_ADDRESS" >>  ~/.vnc/xstartup; \
    echo "startxfce4 &" >>  ~/.vnc/xstartup; \
    echo "[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup" >>  ~/.vnc/xstartup; \
    echo "[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources" >>  ~/.vnc/xstartup; \
    echo "xsetroot -solid grey"  >>  ~/.vnc/xstartup; \
    echo "vncconfig -iconic &    " >>  ~/.vnc/xstartup; \
    sudo chmod +x ~/.vnc/xstartup; \
    touch ~/.Xauthority ;

ENTRYPOINT export USER=realtebo; vncserver :1 && /bin/bash

问题是在运行时我还是收到了密码请求

You will require a password to access your desktops.

如何避免密码请求?

我找到一个窍门

RUN mkdir "$HOME/.vnc" && chmod go-rwx "$HOME/.vnc" ; 

# Configurazione
COPY vncserver        /etc/init.d/vncserver
COPY vncservers.conf  /etc/vncserver/vncservers.conf
COPY startup          /home/realtebo/.vnc/xstartup

RUN \
    /bin/bash -c "echo -e 'password\npassword\nn' | vncpasswd"; echo; \
    sudo chown realtebo:realtebo ~/.vnc/xstartup; \
    sudo chmod +x ~/.vnc/xstartup; \
    touch ~/.Xauthority ;

ENTRYPOINT export USER=realtebo; export DISPLAY=1; vncserver :1 && /bin/bash

重点是我将创建密码文件的方式更改为

/bin/bash -c "echo -e 'password\npassword\nn' | vncpasswd"; echo; \