ubuntudockertightvnc

docker: how to set tightvncserver password?


At the end of my Dockerfile, base on ubuntu:latest I'm preparing all of what I supposed I need to run tightvncserver over xfce4

I configured startup script and setup the password

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

The problem is that at runtime I got the password request anyway

You will require a password to access your desktops.

How can I avoid password request?


Solution

  • I find a trick

    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
    

    The point is I change the way I create the password file to

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