I currently have a codebase for Drupal using Drupal-VM vagrant box and VirtualBox. I would like to migrate to docker but I am unaware on how to integrate it with my existing code base.

Can anyone help me? I have followed instructions from Docker Hub - Drupal Install Steps and MySQL and Drupal Container to spin up mysql and Drupal images but how do I make it point to my pre-existing codebase?

Previous posts with more details, questions and background:

  • 2
    You talking about loval dev environment right? Then go for DDEV, Lando or Docksal. Don't reinvent the wheel. All you maybe need to worry about is the database. But I'd say get one from prod and import locally.
    – leymannx
    Dec 4, 2020 at 19:01
  • @leymannx Currently the database gets built with blt setup, and all the fields and tables are dropped and recreated there. How can i get that to be rebuilt?
    – B. Cratty
    Dec 4, 2020 at 19:08
  • @leymannx I have an issue that I documented here. stackoverflow.com/questions/65206503/… and look at the comments I left on Patrick Kenny's answer
    – B. Cratty
    Dec 8, 2020 at 20:37

2 Answers 2


You can mount host volumes, such as your application codebase, inside your container.

e.g with docker-compose:

    # Mount application codebase
    # - ./project-directory:/container-directory
    - ./project/dir:/var/www/docroot

You can also mount a host volume for your mysql data, to preserve the DB across docker stack rebuild.

    # Database on host
    # - /host-directory:/container-directory
    - /var/lib/my-project/mysql:/var/lib/mysql
  • my site is built with composer and blt. How can I re-create all the tables and fields from all the yml files that are in my config/default?
    – B. Cratty
    Dec 7, 2020 at 19:54
  • @B.Cratty – drush cim?
    – leymannx
    Dec 8, 2020 at 21:50
  • @B.Cratty you can import the config as part of the install process ( drupal.org/node/2897299 ) . It's also possible to restore a DB export, e.g by mounting a folder with the SQL dump and import with drush sqlc < export.sql Dec 9, 2020 at 9:24

You can do this in lando.

Basically, this is the workflow:

  • Configure your lando.yml to get your site running locally and commit this to your repository. This will allow everybody to create a local dev environment as long as they have cloned the repo and have lando installed.
  • Use lando to run the site locally, and continue to commit code/build your project in the same way that you were doing before.

Here are some notes from Acquia on setting up lando with BLT.

  • I just ran through all the steps, and I'm having issues with the blt setup. It keeps failing with the Drupal installation. It gives me a warning [warning] Failed to drop or create the database. Do it yourself before installing. dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /usr/local/bin/mysql Reason: image not found sh: line 1: 71580 Abort trap: 6 mysql --defaults-file=/private/tmp/drush_jEVO19 --database=information_schema --host=localhost --port=3306 --silent -A < /private/tmp/drush_Xugn6U
    – B. Cratty
    Dec 7, 2020 at 19:52
  • Then it says [info] Undefined index: value install.core.inc:2303 [info] Array to string conversion install.core.inc:2303 In install.core.inc line 2307: [Drupal\Core\Installer\Exception\InstallerException] Database settings: Array
    – B. Cratty
    Dec 7, 2020 at 19:52

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.