5

I have successfully installed Magento 2 with sample data using Docker

everything works fine but I have below question.

  • Magento 2 project Base URL is 127.0.0.1 How can I change this URL?
  • What if I want to add more than one project what kind of changes is required for that?

Any help would be appreciated.

Thanks In Advance.

2

For question number 1:

— You can go to docker-compose file and look for apache service then change port to something like 8085:80 then your project baseURL would be like 127.0.0.1:8085 or http://localhost:8085/

For question number 2:

— I believe, 1 docker file for 1 project only. Otherwise, you need to create another docker file for another project.

  • Let me check, If it works I will accept your answer – Sanjay Gohil Jul 8 at 6:39
  • 1
    Suppose I want my project URL like 127.0.0.1/mylatestproject/ than where I want to make changes? @fmsthird – Sanjay Gohil Jul 8 at 6:44
  • I think the best way to do this (if you are on windows OS) is to edit hosts file , from there you can define the name of your custom baseURL . let say, 127.0.0.1 mylatestproject . then you can access your project from web typing mylatestproject – fmsthird Jul 8 at 6:58
  • 1
    +1 for your effort – Sanjay Gohil Jul 9 at 4:09
2

I know maybe this isn't the answer you are expected but I have a different docker compose file for each project. Once I've finished working on one project I docker-compose down -v project, switch to my working copy in my other project and docker-compose up -d

Each project has it's own set of containers which build up a lamp stack. So own db container. But also that way I've got plenty of resouce free for IDE etc

But also that way you're not having to make config changes to switch between stacks. Plus they can all have same url (magento2.docker) and I've got 1 host file entry. Lazy but as docker is dev for me it's okay to take shortcuts.

Docker compose

https://docs.docker.com/compose/install/

And file like this for each project

https://github.com/meanbee/docker-magento2/blob/master/docker-compose.yml

  • 1
    +1 for great information – Sanjay Gohil Jul 9 at 4:09

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.