dockerdockerfilenovnctightvnc

Docker copy file doesn't work with base image


There is a dockerimage https://hub.docker.com/r/oott123/novnc/ which already has /app folder built with it. (and also the github repo for the dockerimage https://github.com/oott123/docker-novnc)

docker-novnc

running the dockerimage without creating my own one works fine because it uses the defauly /app/vncmain.sh. However creating the following Dockerfile and running it doesn't copy the vncmain.sh to /app/vncmain.sh

FROM oott123/novnc:latest

COPY vncmain.sh /app/vncmain.sh

docker build -t myimage/novnc . and the output is as follows:

❯ docker build -t myimage/novnc .
[+] Building 0.2s (7/7) FINISHED
 => [internal] load build definition from Dockerfile                                                               0.0s
 => => transferring dockerfile: 34B                                                                                0.0s
 => [internal] load .dockerignore                                                                                  0.0s
 => => transferring context: 34B                                                                                   0.0s
 => [internal] load metadata for docker.io/oott123/novnc:latest                                                    0.0s
 => [internal] load build context                                                                                  0.0s
 => => transferring context: 32B                                                                                   0.0s
 => [1/2] FROM docker.io/oott123/novnc:latest                                                                      0.0s
 => CACHED [2/2] COPY vncmain.sh /app/vncmain.sh                                                                   0.0s
 => exporting to image                                                                                             0.0s
 => => exporting layers                                                                                            0.0s
 => => writing image sha256:80211fc1f344e7beb50024c08c7bfc4606ccb3e33e97fabdd67412366c2d8577                       0.0s
 => => naming to docker.io/myimage/novnc

it is clearly copying based on the output. However when I run it docker run -p 9000:9000 myimage/novnc

❯ docker run -p 9000:9000 myimage/novnc:latest
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] 010-app: applying...
[fix-attrs.d] 010-app: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 010-setup-vnc: executing...
Would you like to enter a view-only password (y/n)? Password:Verify:[cont-init.d] 010-setup-vnc: exited 0.
[cont-init.d] 020-setup-sudo: executing...
[cont-init.d] 020-setup-sudo: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
xauth:  file /home/user/.Xauthority does not exist
WebSocket server settings:
  - Listen on :9001
  - No SSL/TLS support (no cert file)
  - proxying from :9001 to 127.0.0.1:5911

New 'aff40718fd07:11 (user)' desktop is aff40718fd07:11

Creating default startup script /home/user/.vnc/xstartup
Creating default config /home/user/.vnc/config
Starting applications specified in /home/user/.vnc/xstartup
Log file is /home/user/.vnc/aff40718fd07:11.log

sudo: /app/vncmain.sh: command not found
[cmd] /sbin/entrypoint.sh exited 1
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

Solution

  • You need to make the file executable. After COPY do

    RUN chmod +× /app/vncmain.sh