Question

How can ı Point domain and subdomain 2 or more different docker container ?

Hello, I’m pretty new to this stuff. First of all, I installed docker and nginx on my server. I then used the docker image file located in the nextjs-example folder.Here is example I cloned my project via github and raised it via docker.

Now I want to do something like this. When I log into mydomain.dev it says “This site cannot be reached”. but when I type the ip address of the server into the browser, the project works.

How can I point this to my domain address?

In addition, I want to create a few subdomains. For example project1.mydomain.dev project2.mydomain.dev These will be projects working with different docker image files, how can I integrate them into subdomains.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

This indeed sounds all correct. Once you’ve installed Nginx and started your Docker containers, you would need to setup your Nginx server blocks so that you could define the different domain names for each server blocks.

Here is a quick video that shows how you could do that:

Once your containers are up and running, you can point your subdomain names by adding A records to your DNS zone for those 2 subdomain names to point to your server IP address.

You can follow the steps on how to do that here:

https://docs.digitalocean.com/products/networking/dns/

Also, note that once you make the DNS change it can take up to 24 hours for the DNS to clear over the Globe before you could see the new records.

Let me know how it goes!

Best,

Bobby