5

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

4 Answers 4

0

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.

0

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

0

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

0

For example in markshust/docker-magento box (considered as best) there's a simple command (for everything in fact) to import your existing DB (and existing code/project also) :

You can use the bin/mysql script to import a database, for example a file stored in your local host directory at magento.sql:

bin/mysql < magento.sql

and the command looks like this inside (so it's transparent, and easy) :

#!/usr/bin/env bash
# shellcheck source=../env/db.env
source env/db.env
if [ -t 0 ]; then
  # Need tty to run mysql shell
  bin/cli mysql -h"${MYSQL_HOST}" -u"${MYSQL_USER}" -p"${MYSQL_PASSWORD}" "${MYSQL_DATABASE}" "$@"
else
  # Read from stdin, ex: bin/mysql < dbdump.sql
  bin/clinotty mysql -h"${MYSQL_HOST}" -u"${MYSQL_USER}" -p"${MYSQL_PASSWORD}" "${MYSQL_DATABASE}" "$@"
fi

https://github.com/markshust/docker-magento/blob/master/compose/bin/mysql

I'm like you in the process of switching from Vagrant to Docker, and my main concern is file sync performance between host/guest machine (and maybe how easy to install xdebug)

There's good tutorials and support for this particular box, but it is more oriented to MacOS users, and since I'm on windows ...

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.