skip to Main Content

I have issue after last docker update (seems so) on Windows 10 (local development). When I changed files in PhpStorm (and in another editors – Sublime, Notepad+), after a while, files inside container didn’t receive changes.

Steps that can help for a while:

  • If I completely shut down all containers and after that arise them again. docker-compose down && docker-compoes up
  • If I get into php-fpm container and for file that not changed ran touch file.php (this file will be immidiatly changed).

What I tried and it didn’t help:

  • I restarted php-fpm and nginx containers docker-compose restart php-fpm nginx (Yes it’s strange, because down|up for all container helped)
  • I changed inside PhpStorm setting Use Safe write(save changes for temporary file first)

Also I checked inode for file inside container. With ls -lai file.php. Before changes worked and after they broked I had the same inode number. There is no determined number of changes I must to do to break syncing, it’s random, sometime 2 changes enough.

I have:

Docker version 19.03.5, build 633a0ea

docker-compose version 1.25.2, build 698e2846

docker-compose.yml

version: '3'
services:
    nginx:
        container_name: pr_kpi-nginx
        build:
            context: ./
            dockerfile: docker/nginx.docker
        volumes:
            - ./:/var/www/kpi
            - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
            - ./docker/nginx/fastcgi.conf:/etc/nginx/fastcgi.conf
        ports:
            - "8081:80"
        links:
            - php-fpm
        networks:
            - internal

    php-fpm:
        container_name: pr_kpi-php-fpm
        build:
            context: ./
            dockerfile: docker/php-fpm.docker
        volumes:
            - ./:/var/www/kpi
        links:
            - kpi-mysql
        environment:
            # 192.168.221.1 -> host.docker.internal for Mac and Windows
            XDEBUG_CONFIG: "remote_host=host.docker.internal remote_enable=1"
            PHP_IDE_CONFIG: "serverName=Docker"
        networks:
            - internal

    mailhog:
        container_name: pr_kpi-mailhog
        image: mailhog/mailhog
        restart: always
        ports:
            # smtp
            - "1025:1025"
            # http
            - "8025:8025"
        networks:
            - internal

    kpi-mysql:
        container_name: pr_kpi-kpi-mysql
        image: mysql:5.7
        command: mysqld --sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
        volumes:
            - ./docker/storage/kpi-mysql:/var/lib/mysql
        environment:
            # We must change prod secrets, this is not good approach
            - "MYSQL_ROOT_PASSWORD=pass"
            - "MYSQL_USER=user"
            - "MYSQL_PASSWORD=user_pass"
            - "MYSQL_DATABASE=kpi_db"
        ports:
            - "33061:3306"
        networks:
            - internal

    kpi-npm:
        container_name: pr_kpi-npm
        build:
            context: ./
            dockerfile: docker/npm.docker
        volumes:
            - ./:/var/www/kpi
            - /var/www/kpi/admin/node_modules
        ports:
            - "4200:4200"
        networks:
            - internal
        tty: true


# For xdebug
networks:
    internal:
        driver: bridge
        ipam:
            driver: default
            config:
                - subnet: 192.168.221.0/28

P.S. There is opened issue:
https://github.com/docker/for-win/issues/5530

P.P.S. We need to update Docker from 2.2.0.0 to 2.2.0.3, Seems it’s fixed

2

Answers


  1. I have the same issue on Windows10 since 31st Jan.
    I have commented a line in PhpStorm and checked it in the container using vim.
    The changes were not there.
    If I run docker-compose down and up, the changes go in the container.

    Docker version 19.03.5, build 633a0ea
    docker-compose version 1.25.4, build 8d51620a

    Nothing changed in my docker-compose.yml since 2018.

    Login or Signup to reply.
  2. I have a separate container for syncing my folder:

    app:
        image: httpd:2.4.38
        volumes:
            - ./:/var/www/html
        command: "echo true"
    

    I just use the basic apache image, you could use anything really though. Then in my actual containers, I use the following volumes_from key:

    awesome.scot:
        build: ./build/httpd
        links:
            - php
        ports:
            - 80:80
            - 443:443
        volumes_from:
            - app
    
    php:
        build: ./build/php
        ports:
            - 9000
            - 9001
        volumes_from:
            - app
        links:
            - mariadb
            - mail
        environment:
            APPLICATION_ENV: 'development'
    

    I’ve never had an issue using this set up, files always sync fast, and I have tested both on Mac OSX and MS Windows.

    If you’re interested, here is my full LAMP stack on Github https://github.com/delboy1978uk/lamp

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search