Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sys Auditing's avatar

Prevent syncering Compose change from Container to Dev machine

Hi, i have a project with Laravel and Docker. when executing compose install inside container many files change and synced with localhost repos using volume. And git tell me those files are changed in my local dev machine.

My question how to prevent those change to synced with my local repo?

Thank you

0 likes
3 replies
brainpalen's avatar

I think you should exclude the container-specific files. Identify the files that are being modified inside the Docker container and causing the changes to be synced with your local repository. Then, create or modify a .gitignore file in the root directory of your local repository. Add the paths or patterns of the files you want to exclude from being tracked by Git. For example, if the modified files are located in a directory named container-files, you can add the following line to your .gitignore file:

container-files/

Next, you need to manage separate configuration files. If the changes are happening to configuration files, consider creating separate configuration files specific to the Docker container. In your repository, provide template or default configuration files that can be copied and modified by users in their local environments or Docker containers. Add the actual configuration files to the .gitignore file to exclude them from version control. basket random You can then provide their specific configuration files locally or within the Docker container without affecting the repository.

martinbean's avatar

when executing compose install inside container many files change and synced with localhost repos using volume. And git tell me those files are changed in my local dev machine.

@sys auditing Running composer install only installs the packages declared in your composer.lock file, and installs files/folders to your vendor directory. The vendor directory should be present in your .gitignore file, so running composer install should not be changing “many files”, nor should they be showing as changed in Git… because they shouldn’t be tracked by Git in the first place.

Please or to participate in this conversation.