Automating createsuperuser in docker


I’m attempting to automate the docker install in ansible.

I’m stuck on creating the super user.

I have: docker exec -it funkwhale-api python createsuperuser --username admin --email [email protected]

It still prompts for the admin users password. Is there a way to add a password with like a --password option or some other way to accomplish this without manually entering in the password?

Thank you!


I found my solution. If anyone else needs it:

docker exec -it funkwhale-api python shell -c "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', '[email protected]', 'ChangeMe!')"


Hi there!

Indeed, there is no way to specify the password from commandline using a flag, that’s a limitation of the django command we’re using.

Your solution is the best one I can think of :slight_smile: