1

How do you run magento commands when using a docker container, like

php bin/magento setup:deploy

I have a docker container with php 7, mysql 5.6. The website works ok, but if I try to run some magento commands it tries to run them through the system php, which is 5.4.

It is more of a docker workflow question, as I'm unsure what to do next. I tried docker exec 281cbd203f92 magento setup:upgrade but obviously it doesn't recognize the magento command. Should I add it to the path in the container?

My container:

281cbd203f92        cloudwaysdocker/docker_debian   "/bin/bash /start.sh"   5 days ago          Up 3 hours          0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   magento2

1 Answer 1

2

I guess you can solve it by running Magento commands inside container. You need to login into container first:

docker exec -ti 281cbd203f92 /bin/bash

After that you need to change current directory to document root of your Magento, add path to /bin/magento to container PATH variables like:

export PATH=$PATH:/var/www/html/magento2/bin

After that you can run magento commands inside and outside container.

Your Answer

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

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