-
Notifications
You must be signed in to change notification settings - Fork 193
Description
Describe the bug
After successfully starting the DocumentDB Docker container and connecting to the database, restarting the container causes it to fail. The container attempts to re-insert sample data on every restart, which results in a duplicate key violation error since the data already exists from the initial startup.
Reproduction Steps
Steps to reproduce the behavior:
Follow the README instructions at https://github.com/documentdb/documentdb/blob/main/README.md to pull and start the Docker container
Connect to the database successfully
Stop the Docker container (docker stop <container_name>)
Restart the Docker container (docker start <container_name>)
Observe that the container fails to start properly
Expected behavior
The Docker container should restart successfully without attempting to re-insert sample/initialization data that already exists in the database.
Actual behavior
The container fails to start on restart with the following error in the logs:
MongoBulkWriteError: Duplicate key violation on the requested collection: Index 'id'
Workaround
Dropping the entire database before restarting the container resolves the issue
Additional context
-
This appears to be a Docker image initialization script issue where the entrypoint/startup script unconditionally runs data insertion without checking if the data already exists.
-
Suggested fix: The initialization script should either:
- Check if data already exists before inserting, or
- Only run on first-time container initialization (not on restarts)