Is there a way to run my existing magento 2 project inside a docker container? I have an existing project that is run inside a vagrant but I'm encountering a lot of issue in the vagrant and we decided to use docker for this. But I don't know how to migrate my existing magento project from vagrant to docker. I have search for various tutorial but all of them teach how to install magento inside a docker so all DB contents and setup are made during this process. But what if I already have my DB and my projects setup. I just want to like COPY Paste my codes inside a docker container.

If anyone of you can show me step by step on what I should consider or do when I want to migrate my magento project to docker. So I was thinking like I need to migrate my DB first to my MYSQL/DB container then copy paste my code to somewhere and modify docker-compose.yml to somewhere... But I don't know how and what. Would appreciate any help please.

Also I would like to use docker-compose.yml here and I'm ok if a Dockerfile will be used together with the docker-compose.yml file

3 Answers 3


all of them teach how to install Magento inside a docker so all DB contents and setup are made during this process

For the simple solution, After installing the fresh Magento setup you can change the codebase and database as you want.

Please create shared volume while creating a docker container then later replace the codebase and database.

I hope it helps.


You might still have to tweak some things like url or magento version. You can't use a service like docker and know nothing about it. The following is a repo that contains a docker 'box' for local magento2 development. It also contains steps on how to install it. It's pretty straight forward. You can migrate your db afterwords and bring you code either with composer or with git or the old copy-paste if your feeling retro.

Hope this helps. https://github.com/victortodoran/magento2-docker


One of the best docker instances for Magento that we use is https://github.com/davidalger/warden

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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