这是我的文件夹结构的样子
- 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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句