[英]Docker copy not work, content not updated
I try to configure docker with php(symfony app). 我尝试用php(symfony app)配置docker。
When I build container for first time, symfony skeleton app appears in container, but any other builds sasdoes not change anything inside container. 当我第一次构建容器时,symfony骨架应用程序出现在容器中,但是其他任何构建方法都不会更改容器内的任何内容。
Dockefile Dockefile
FROM nginx:latest
RUN rm ./etc/nginx/conf.d/default.conf
COPY ./nginx/site.conf /etc/nginx/conf.d/site.conf
COPY . /var/www/html
CMD ["nginx", "-g", "daemon off;"]
docker-compose 码头工人组成
version: '3'
services:
simple-app-symfony:
image: simple-app-symfony
build: .
ports:
- "8080:80"
links:
- php
volumes:
- data:/var/www/html
php:
image: php:7.1-fpm
volumes:
- data:/var/www/html
volumes:
data:
nginx/site.conf nginx / site.conf
server {
listen 80;
listen [::]:80;
server_name ~.;
root /var/www/html/public;
index index.php index.html index.htm;
#location ~ \.php$ {
# try_files $uri =404;
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass php:9000;
# fastcgi_index index.php;
# include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param PATH_INFO $fastcgi_path_info;
#}
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass php:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
internal;
}
location ~ \.php$ {
return 404;
}
}
I tried docker-compose build --no-cache, docker build . 我尝试了docker-compose build --no-cache,docker build。 -t simple-app-symfony -> nothing changes. -t simple-app-symfony->没有任何变化。 Any ideas whats going on? 有什么想法吗? I think that the problem is with volumes, because it I removed volume's secition, the container has been updated. 我认为问题出在卷上,因为我删除了卷的分区,因此容器已更新。
But I need volumes mapping, because in this case, php needs to have access, to source code 但是我需要卷映射,因为在这种情况下,php需要访问源代码
You are changing the contents of /var/www/html
in two conflicting steps: 您正在两个冲突的步骤中更改/var/www/html
的内容:
COPY
instruction in Dockerfile copies files in build context to container's /var/www/html
folder. Dockerfile中的COPY
指令将构建上下文中的文件复制到容器的/var/www/html
文件夹中。 To fix this, remove the COPY
instruction in Dockerfile, and use bind-mount in docker-compose to mount you source code folder to container's /var/www/html
. 要解决此问题,请删除Dockerfile中的COPY
指令,然后在docker-compose中使用bind-mount将源代码文件夹安装到容器的/var/www/html
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.