Docker会覆盖文件吗?

时间:2017-06-16 21:13:05

标签: docker

我有非常简单的Dockerfile:

FROM wordpress

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

它创建2个文件,file1.txt到/ var / www /和file2.txt到/ var / www / html /

然后我构建它:docker build -t 'wp' . 之后我运行它:

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

现在,如果我看看里面:

=> 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不存在。它已经消失了,因为wordpress被复制了吗?

如何在file2.txt内同时使用wordpress和/var/www/html/

1 个答案:

答案 0 :(得分:1)

根据https://github.com/docker-library/wordpress/blob/0a5405cca8daf0338cf32dc7be26f4df5405cfb6/php5.6/apache/docker-entrypoint.sh#L33的入口点脚本,它正在设置来自/usr/src/wordpress的wordpress。因此,您可以将文件复制到/usr/src/wordpress,然后在由入口点脚本复制时最终生成/var/www/html