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 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 Answers 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 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 Jul 8, 2019 at 6:39
  • 1
    Suppose I want my project URL like than where I want to make changes? @fmsthird Jul 8, 2019 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, mylatestproject . then you can access your project from web typing mylatestproject
    – fmsthird
    Jul 8, 2019 at 6:58

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


And file like this for each project



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.