gpt4 book ai didi

docker - .dockerignore 不会忽略列出的文件夹和文件

转载 作者:行者123 更新时间:2023-12-05 06:27:01 27 4
gpt4 key购买 nike

我的文件夹结构是这样的

- myapp
-- public
-- other_dirs
-- docker // contain all the Dockerfiles and configuration files etc
-- vendor
-- .gitignore
-- .dockerignore
-- README.md

在我使用的 Dockerfile 中,我有这个以便在容器中复制我的所有应用程序

FROM php:7.1-apache-stretch

COPY . /var/www/html

WORKDIR /var/www/html/

这是 docker-compose 文件

version: '3'

services:
app:
image: myapp
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 8080:80
networks:
- appnet

这就是我的 .dockerignore 文件的样子

.git
.gitignore
vendor/

当我运行 docker-compose up --build 然后 exec 进入我的应用程序容器时,如果我执行 ls -lah 我仍然可以在列表中看到我在.dockerignore文件中添加的文件夹和文件。知道我做错了什么吗?

最佳答案

您看到这些文件是因为您正在目录中安装卷。要修复它,请查看:Make docker-compose ignore folder within volume

关于docker - .dockerignore 不会忽略列出的文件夹和文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55674437/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com