Reputation: 4467
This is how my folder structure looks like
- myapp
-- public
-- other_dirs
-- docker // contain all the Dockerfiles and configuration files etc
-- vendor
-- .gitignore
-- .dockerignore
-- README.md
In the Dockerfile I use I have this in order to copy all my app within the container
FROM php:7.1-apache-stretch
COPY . /var/www/html
WORKDIR /var/www/html/
And this is the docker-compose file
version: '3'
services:
app:
image: myapp
build:
context: .
dockerfile: docker/Dockerfile
volumes:
- .:/var/www/html
ports:
- 8080:80
networks:
- appnet
and this is how my .dockerignore
file looks like
.git
.gitignore
vendor/
When I run docker-compose up --build
and then exec
to enter my app container, if I do ls -lah
I can still see in the list the folders and files I have added in the .dockerignore
file. Any ideas what I'm doing wrong?
Upvotes: 3
Views: 4887
Reputation: 2524
You are seeing the files because you are mounting the volume in the directory. To fix it, please take a look at: Make docker-compose ignore folder within volume
Upvotes: 2