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!

2
  • Could you run 'ls' in yours local directory with dockerfile? Apr 11, 2020 at 6:47
  • @matchish That is in the first row of my screenshot. There are 2 files contained: Dockerfile and config.php
    – ch-pub
    Apr 11, 2020 at 7:01

1 Answer 1

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
    
3
  • 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, 2020 at 7: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 github.com/nextcloud/docker#persistent-data Apr 11, 2020 at 7: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: stackoverflow.com/questions/61159869/…
    – ch-pub
    Apr 11, 2020 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.