Docker container not started

My mongo DB container getting exited immediately while using MONGO_INITDB_ROOT_USERNAME, MONGO_INITDB_ROOT_PASSWORD parameter.

I used below command

docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USER=username -e MONGO_INITDB_ROOT_PASSWORD=password --network mongo-network --name mongodb mongo:latest

getting error

error : missing ‘MONGO_INITDB_ROOT_USER’ or ‘MONGO_INITDB_ROOT_PASSWORD’ both must be specified for a user to be created .

Split the long docker run command into multiple lines using back slashes() and see if it works
You can also check our forum threads
Some sample run commands are documented

I have tried after split also and got same error. Can I set MONGO_INITDB_ROOT_USER and MONGO_INITDB_ROOT_PASSWORD parameter value after run container. If possible then which file, I need to modify.

I have not used docker but there is lot of documentation on it
Did you check our forum threads?
You need to check your env files, docker-compose.yml
Also check stackoverflow threads