MongoDB with volume fails to authenticate after duplication (environment creation)
Hello there,
When i create a new environment, already containing a MongoDB instance on the main env, it tries to duplicates it, without any ENV Variables (?), and once i import all the variables from de main environment, the MongoDB instance fails to authenticate (on the "Data" tab of the MongoDB service).
I'm a bit confused of the "duplication" behavior, without env vars, and i don't understand why it does not work after i import the variables as well.
Thanks for helping !
![No description](https://cdn.answeroverflow.com/1168972460075520051/image.png)
![No description](https://cdn.answeroverflow.com/1168972460570460291/image.png)
![No description](https://cdn.answeroverflow.com/1168972461044408391/image.png)
Solution:Jump to solution
- in the main environment's mongodb service set a service variable
MONGO_DBPATH
to ${{RAILWAY_VOLUME_MOUNT_PATH}}
- cancel the popup
- in the mongodb service settings set this start command /bin/sh -c "docker-entrypoint.sh mongod --dbpath ${MONGO_DBPATH} --ipv6 --bind_ip ::,0.0.0.0"
- don't cancel the popup
- create your new environment in the projects settings...21 Replies
Project ID:
fa4f3b3c-8eb7-43a6-a995-0619ad7c212c
fa4f3b3c-8eb7-43a6-a995-0619ad7c212c
if you want to create a duplicate environment with all variables the same, you want to use forked environments
https://docs.railway.app/develop/environments#forking-and-merging-environments
Thanks for the reply, i'm not really looking to completely "clone" my environment, just create independant environments "prod, dev, preprod", with the same architecture but with their own data.
The problem is the behavior of the MongoDB service with i create a new environment, would you be alright to explain what I need to do with the variables to make it work ?
though i understand they confusion, the reason why the database couldn't be connected to even after adding all the variables back to it is likely because it was already deployed and initialized itself with no variables, this seems like it messed something up internally in the container. in my opinion that flow should not auto deploy anything and instead ask you to setup the variables and then give you a deploy now button for when you have all variables setup
Alright ! Thats what i was testing and it seems to be the case, because i also have a volume connected to the service. Problem is if i decide to delete the volume to restart the deployment with the variables, the volumes of all the other environments get deleted as well π
Is there a possibility to reset a volume on one environment only ?
let me see if i can come up with a flow to solve this
The solution i came up with is to stop de deployment as fast as possible to not write anything on the partition, then import the variables, then re-deploy
thats what im thinking, but doing that is hard, docker images deploy fast and mongo could write garbage to the volume before you are able to abort
It would be great to have a "Deploy" button floating top right (or any other place) on the dashboard, to click when the user finish to setup the environment
Yes, had to do it 3 times before a success
yeah and not have anything auto deploy, because 9 times out of 10 (made up number) a service will fail without any variables set
Thanks for the help ! Can I mark this thread as solved ?
not solved yet, i havent come up with a flow that works every time yet
Oh you are still on it, thanks !
of course