Search code examples
dockerdocker-composeddev

Installed packages & /home/* files sometimes reset on ddev restart (or ddev stop, start)


I've been using DDEV for a few days and it's great.

However I have found if I run ddev ssh to ssh into the container, and install packages via npm / aptitude etc, or if I create new files in the ~/ home directory, sometimes those packages / files get removed / reset when I ddev stop > ddev start or ddev restart

It doesn't happen all the time, just sometimes. I've restarted it a bunch of times, and I can't work out any pattern as to when the packages/files get wiped, and when they don't.

I've trawled through the config files, and the documentation, and the github issue queue, but I can't find anything about it. I am running the ddev on a Mac, installed with Homebrew. I have the latest version of Docker and Docker Compose.

My question is: How can I make it so my installed packages / files will persist when I restart ddev?

Many thanks.


Solution

  • When you just ddev ssh and install, everything is thrown away when the container is recreated or rm'd.

    Edit: As of ddev v1.8.0, you can just use webimage_additional_packages: [php7.1-ldap], see docs

    Original approach:

    Try this post-start hook example from the docs. This general approach should work well.

    hooks:
        post-start:
          # Install php modules and then tell php-fpm to reload
          - exec: "sudo apt-get update && sudo apt-get install -y php7.1-ldap php7.1-tidy && killall -HUP php-fpm"