3

I'm trying to deploy a Nextcloud container, where the config is copied from the local directory to the container. I'm not getting any error when building or running the container, and I can see the steps are successfully executed per the terminal. Regardless, the copied file simply is not in the container. What's going on here?

Dockerfile:

FROM nextcloud:latest

# Copy local config
COPY ./config.php /var/www/html/config

All the evidence: Local file COPY not working

Thanks!

ch-pub
  • 1,664
  • 6
  • 29
  • 52

1 Answers1

3

The file is copied but is being deleted later.

This is a very typical scenario, and in this cases, the best you can do is to see what happens in the parent image nextcloud:latest once the container starts.

In nextcloud's Dockerfile you can see

ENTRYPOINT ["/entrypoint.sh"]

if we open entrypoint.sh in the line 100 you can see clearly that the content of /var/www/html/config is modified

You can maybe do any of these options

  • Copy the file to a different temporary location, and create your own entrypoint (you can copy-paste from the original one to hit the ground running, or you can try to figure out a fancier solution)

  • Or also you can copy the file after creating and running the container

    docker cp config.php copytest:/var/www/html/config
    
Carlos Robles
  • 10,828
  • 3
  • 41
  • 60
  • 1
    Perfect, thanks! Actually I'm using docker-compose (omitted from my OP). Then would you just add the file as a mounted volume? – ch-pub Apr 11 '20 at 07:25
  • 1
    Since entrypoint.sh is doing a RSYNC still it could be deleted, but apparently nextcloud recommends exactly using volumes, so yes you can give it a try. take a look at this one https://github.com/nextcloud/docker#persistent-data – Carlos Robles Apr 11 '20 at 07:29
  • Actually, I'm trying to use a volume mounting solution, and still running into (similar?) errors... I opened a new post about this here, in case you're familiar with Nextcloud issues: https://stackoverflow.com/questions/61159869/cannot-mount-config-directory-in-nextcloud-docker-container – ch-pub Apr 11 '20 at 17:18