We are also running into all of the issues described here. I did manage to find a workaround for #2 (container restarts). You can intercept the container kill signal in your entrypoint script and pause the deployment:
atlas-entrypoint
#!/usr/bin/env bash
DEPLOYMENT_INFO=$(atlas deployments list | grep 'my_deployment')
if [[ $DEPLOYMENT_INFO ]]; then
# Restart a deployment
atlas deployments start my_deployment
else
# Create a new deployment
atlas deployments setup my_deployment --type local --port 27778 --username root --password root --bindIpAll --skipSampleData --force
fi
# Pause the deployment whenever this container is shutdown to avoid corruption.
function graceful_shutdown() {
atlas deployments pause my_deployment
}
trap 'graceful_shutdown' EXIT
sleep infinity &
wait $!
docker-compose.yml
...
mongodb_atlas:
container_name: 'mongodb_atlas'
image: 'mongodb/atlas:v1.14.2'
ports:
- '27778:27778'
privileged: true
entrypoint: '/home/scripts/atlas-entrypoint'
volumes:
- './scripts:/home/scripts'
Haven’t tested it extensively but it at least works when you run docker compose down.
Importantly, this does not work if you use tail -f /dev/null as suggested in the docs. I had to switch that to the sleep and wait commands shown above.