"My app connects to DigitalOcean Managed MongoDB via
podman run, but fails viapodman-compose. What networking, DNS, or Podman rootless differences cause this, and how do I fix it?"
DigitalOcean uses an IP whitelist ("Trusted Sources").
podman runuses your host's network directly, so DigitalOcean sees your normal, whitelisted IP.podman-composecreates an isolated network bridge using a proxy (slirp4netns/pasta). This proxy can alter or misroute outbound traffic, causing DigitalOcean to see an unauthorized request and block it.
{
"name": "mongo-test",
"version": "1.0.0",
"main": "test.js",
"dependencies": {
"mongoose": "^8.0.0"
}
}
const mongoose = require('mongoose');
const uri = process.env.MONGO_URI;
if (!uri) {
console.error('β ERROR: MONGO_URI missing!');
process.exit(1);
}
console.log('π Connecting to DigitalOcean MongoDB...');
mongoose.connect(uri)
.then(() => {
console.log('β
SUCCESS: Connected!');
process.exit(0);
})
.catch((err) => {
console.error('β FAILED:', err.message);
process.exit(1);
});# 1. Start compose stack
podman-compose up -d
# 2. Install dependencies inside container
podman exec -it <container_name> sh -c "apk add --no-upgrade nodejs npm || apt-get update && apt-get install -y nodejs npm"
podman exec -it <container_name> npm install mongoose
# 3. Copy script into container
podman cp test.js <container_name>:/test.js
# 4. Run test script using container's MONGO_URI
podman exec -it <container_name> node /test.js
β SUCCESS= Network/IP is working. Check app code or variable typos.- Timeout / Hang = DigitalOcean IP whitelist is blocking
podman-composetraffic. ENOTFOUND=podman-composenetwork DNS failure.