Kert Kukk
Kert Kukk

Reputation: 715

Docker overwrites files?

I have very simple Dockerfile:

FROM wordpress

RUN touch /var/www/file1.txt
RUN touch /var/www/html/file2.txt

It create 2 files, file1.txt to /var/www/ and file2.txt to /var/www/html/

Then I build it: docker build -t 'wp' . and after that I run it:

=> docker run --name "wpcontainer" wp
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html

Now if I look inside:

=> docker exec -it wpcontainer bash
root@e00c5da7ba67:/var/www/html# ls
index.php    wp-activate.php     wp-comments-post.php  wp-cron.php    wp-load.php   wp-settings.php   xmlrpc.php
license.txt  wp-admin        wp-config-sample.php  wp-includes    wp-login.php  wp-signup.php
readme.html  wp-blog-header.php  wp-content        wp-links-opml.php  wp-mail.php   wp-trackback.php
root@e00c5da7ba67:/var/www/html# cd ..
root@e00c5da7ba67:/var/www# ls
file1.txt  html

file2.txt isn't there. It is gone probably because wordpress was copied over it?

How can I have both, wordpress and file2.txt inside of /var/www/html/?

Upvotes: 1

Views: 1119

Answers (1)

Andy Shinn
Andy Shinn

Reputation: 28543

According to the entrypoint script at https://github.com/docker-library/wordpress/blob/0a5405cca8daf0338cf32dc7be26f4df5405cfb6/php5.6/apache/docker-entrypoint.sh#L33 it is setting up wordpress from /usr/src/wordpress. So, you could copy the file to /usr/src/wordpress instead and it would then end up in the resulting /var/www/html when copied by the entrypoint script.

Upvotes: 2

Related Questions