If you've ever deployed a Docker container to a cloud platform, you know the drill: you get a URL like random-name-12345.platform.dev. It works, but showing that to clients or putting it on your resume? Not ideal.
In this guide, I'll show you how to connect your own domain (like api.mycompany.com) to a Docker container with automatic free SSL certificates. No manual certificate management, no nginx configuration headaches.
Why Custom Domains Matter
Before diving into the how, let's talk about the why:
Professionalism: api.yourcompany.com looks better than container-xyz.platform.dev
SEO: Your domain builds authority, platform subdomains don't
Portability: If you switch providers, your users' bookmarks still work
Trust: Users recognize and trust your domain
Prerequisites
To follow along, you'll need:
A deployed Docker container (I'm using SnapDeploy, but the DNS concepts apply anywhere)
A domain you own
Access to your domain's DNS settings
Step 1: Add Your Domain in the Dashboard
First, navigate to your container's settings and find the Custom Domains section.
Container Settings → Custom Domains → Add Domain
Enter your domain exactly as you want it to appear:
For a subdomain: api.example.com
For root domain: example.com
After adding, you'll receive an IP address to point your DNS to. Copy this - you'll need it in the next step.
Step 2: Configure DNS with A Records
Here's where many tutorials get it wrong. They tell you to use CNAME records, but A records are actually better for container hosting:
Why A Records over CNAME:
Works for both root domains (example.com) and subdomains (api.example.com)
No CNAME flattening issues
Direct IP resolution = faster DNS lookups
More reliable for load-balanced infrastructure
Setting Up Your A Record
Go to your DNS provider and create a new A record:
Setting Value
Type A
Name @ (for root) or api (for subdomain)
Value The IP address from Step 1
TTL 300 (or Auto)
Provider-Specific Instructions
Cloudflare:
Go to DNS → Records → Add record
Type: A
Name: Your subdomain or @ for root
IPv4 address: Paste the IP from your container platform
Proxy status: Either works (orange or grey cloud)
Save
Namecheap:
Domain List → Manage → Advanced DNS
Add New Record → A Record
Host: @ or subdomain name
Value: The IP address
TTL: Automatic
GoDaddy:
My Products → DNS → Manage
Add → A Record
Name: @ or subdomain
Value: IP address
TTL: 600 seconds
Step 3: Wait for DNS Propagation
DNS changes aren't instant. Here's what to expect:
Best case: 5-10 minutes
Typical: 15-30 minutes
Worst case: Up to 48 hours (rare)
You can check propagation status at dnschecker.org by entering your domain and selecting "A" record.
Step 4: SSL Certificate Auto-Provisioning
Here's the best part: you don't have to do anything.
Once DNS propagates, the platform automatically:
Detects your domain is pointing to the correct IP
Requests a Let's Encrypt SSL certificate
Installs and configures the certificate
Sets up automatic renewal
Within 5-10 minutes of DNS propagation, your site will be accessible at https://yourdomain.com with a valid SSL certificate.
Verifying SSL
Check your SSL is working:
curl -I https://yourdomain.com
You should see HTTP/2 200 and the response should come through without SSL errors.
Troubleshooting Common Issues
"Domain not verifying"
Cause: DNS hasn't propagated yet.
Fix:
Wait 30 minutes
Check dnschecker.org for propagation status
Verify you entered the correct IP address
"SSL certificate not working"
Cause: Usually DNS is pointing to wrong IP.
Fix:
Verify A record points to the exact IP shown in your dashboard
If using Cloudflare with proxy (orange cloud), ensure your platform supports it
Clear your browser cache and try again
"Mixed content warnings"
Cause: Your app is loading resources over HTTP instead of HTTPS.
Fix: Update your application to:
Use relative URLs (/api/endpoint instead of http://...)
Or use protocol-relative URLs (//example.com/resource)
Or explicitly use HTTPS URLs
"ERR_TOO_MANY_REDIRECTS"
Cause: SSL mode conflict (common with Cloudflare).
Fix: In Cloudflare, set SSL/TLS mode to "Full" or "Full (strict)".
How This Compares to Other Platforms
I've set up custom domains on multiple platforms. Here's how the experience differs:
Platform DNS Record Type Free SSL Root Domain Support Setup Complexity
SnapDeploy A Record Yes Yes Simple
Render CNAME Yes Requires workaround Medium
Railway CNAME Yes Requires CNAME flattening Medium
Heroku CNAME Yes (paid plans) No Complex
Fly.io A/AAAA Yes Yes Medium
The main advantage of A record-based systems: you can use root domains (example.com) without CNAME flattening or special DNS provider features.
Plan Requirements
On SnapDeploy specifically:
Plan Custom Domains
Free Subdomain only
Hobby ($9/mo) Subdomain only
Starter ($39/mo) 2 domains
Pro ($89/mo) 5 domains
Business ($169/mo) Unlimited
Best Practices
- Use subdomains for APIs
api.yourapp.com → Your backend
app.yourapp.com → Your frontend
Set up both www and non-www
Add both example.com and www.example.com, then redirect one to the other for consistency.Keep DNS TTL low during setup
Use 300 seconds (5 minutes) while setting up. Increase to 3600+ once everything works.
Wrapping Up
Custom domains with SSL used to require:
Manual certificate generation
Nginx/Apache configuration
Certificate renewal cron jobs
Load balancer setup
Now it's:
Add domain in dashboard
Create A record
Wait 10 minutes
That's real progress.
Have questions about setting up custom domains? Drop a comment below.
Building something cool? SnapDeploy offers Docker container hosting with automatic SSL and custom domain support starting at $39/mo.
Top comments (0)