I'm using the Docker DevBox (Beta) from Magento for development. Unfortunately, after developing a while, it seems that the container caches everything. Sometimes it helps when I restart Docker. In the worst case, I have to initiate the Docker container again (via m2devbox-init.sh).

Developing environment details:

  • macOS Sierra (10.12.3)
  • Docker Community Edition (17.03.1-ce-mac5 (16048), channel stable)
  • Current DevBox with Magento v. 2.1.5 (not modified)

I had the same problem with two different Magento 2 projects now, so I assume it does not depend on third party Magento modules.

In the Docker container, I can't restart php-fpm by typing "service php-fpm restart" because there seems to be no service with this name.

# sudo service --status-all              
 [ + ]  apache2
 [ - ]  bootlogs
 [ - ]  bootmisc.sh
 [ - ]  checkfs.sh
 [ - ]  checkroot-bootclean.sh
 [ - ]  checkroot.sh
 [ + ]  cron
 [ - ]  exim4
 [ - ]  hostname.sh
 [ ? ]  hwclock.sh
 [ - ]  killprocs
 [ - ]  motd
 [ - ]  mountall-bootclean.sh
 [ - ]  mountall.sh
 [ - ]  mountdevsubfs.sh
 [ - ]  mountkernfs.sh
 [ - ]  mountnfs-bootclean.sh
 [ - ]  mountnfs.sh
 [ - ]  procps
 [ - ]  rc.local
 [ - ]  rmnologin
 [ - ]  rsync
 [ - ]  sendsigs
 [ + ]  ssh
 [ - ]  sudo
 [ - ]  supervisor
 [ + ]  udev
 [ ? ]  udev-finish
 [ - ]  umountfs
 [ - ]  umountnfs.sh
 [ - ]  umountroot
 [ - ]  urandom
 [ - ]  x11-common

But of course, there is php-fpm running (you can see it in the active processes).

I have tried the following steps to flush the cache:

  • run "bin/magento cache:flush"
  • deleted static content files and cache from file system
  • created a php file with "opcache_reset()" in it and run it
  • killed all php-fpm processes
  • flushed the cache in the Magento backend
  • completely disabled the cache with "bin/magento cache:disable"
  • developer mode is turned on, of course

Something in this container is caching my code. It's caching php, JavaScript and phtml-template files. The Docker container is a good tool to work with, but this caching problems take so much time that I have to temporary switch back to XAMPP until, hopefully, someone can help me.

2 Answers 2


OPCache is causing this problem. You have to create a php file (eg. reset_opcache.php) which is accessible via browser and put the following code inside:

<?php opcache_reset(); ?>

Assuming your project url is and you put the file in the Magento root folder, open in your browser. There will be no output, but your changes will now affect.

You can also call the file from your terminal, but the cgi php uses another (or no) OP Cache. So it won't affect your changes.

If your reset_opcache.php is not accessible via browser (because obviously OP Cache is 'preventing' you from calling the file), try restarting the container, or restarting Docker, or - in the worst case - restarting your machine. As long as you can access the file in the browser.


It's happened here, it issue has happened because I selected to use Redis and Varnish.

But first run this command to clean the OPCache to check:

php -r "opcache_reset();" 

You can disable that, clicking on this option below Show Advanced Options:

Show Advanced Options

So unselect the Redis and Varnish:

Redis and Varnish DevBox Magento 2

When run in your machine, inside of your Docker container execute:

alias mage="php -d memory_limit=-1 -f bin/magento"
mage deploy:mode:set developer
chmod -R 775 pub/static/ var/ pub/media/ &&
rm -rf var/view_preprocessed/ var/cache/ var/page_cache/ var/tmp/ var/generation/ pub/static/frontend/ ;
mage cache:disable &&
mage indexer:reindex &
mage setup:upgrade &&
mage setup:static-content:deploy && 
mage setup:db-data:upgrade &&
mage dev:source-theme:deploy &&
chmod -R 775 pub/static/ pub/media/ var/
  • I did not chose any caching option on the download page of Magento. I also tried the commands, but not as one command chain. Some of these commands also may be redundant, as you first disable the cache, then you clean and flush it. Is this really necessary? Thanks for your help.
    – TKly
    Commented Apr 19, 2017 at 9:48
  • I've removed the redundant code, these options are selected by default you need to access the advanced options to unselect. Commented Apr 19, 2017 at 13:56
  • When I go to the Magento DevBox download page, these options are not selected by default. Also, if you get your download, there is a docker-compose.yml file where caches should be set to 0 by default. In my case, the cache is set to 0. I slowly think it comes from PHP OPCache.
    – TKly
    Commented Apr 21, 2017 at 8:18
  • thank you for your help. I finally found out what is caching my files. It was the OPCache, but the way I cleaned it, was wrong. I will post the solution.
    – TKly
    Commented Apr 24, 2017 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.