{"id":812,"date":"2018-06-06T08:59:06","date_gmt":"2018-06-06T08:59:06","guid":{"rendered":"http:\/\/www.selinuxplus.com\/?p=812"},"modified":"2018-06-06T08:59:49","modified_gmt":"2018-06-06T08:59:49","slug":"docker-admin-user-is-created-twice","status":"publish","type":"post","link":"http:\/\/www.selinuxplus.com\/?p=812","title":{"rendered":"Docker: Admin user is created twice"},"content":{"rendered":"<p>#01  <\/p>\n<pre class=\"lang:default decode:true \" >django.db.utils.IntegrityError: duplicate key value violates unique constraint \"auth_user_username_key\"\r\nDETAIL:  Key (username)=(admin) already exists.<\/pre>\n<p>#02<\/p>\n<pre class=\"lang:default decode:true \" >@ -13,7 +13,12 @@ if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD}\r\n         SUPERUSER_PASSWORD='admin'\r\n         echo \"Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}\"\r\n fi\r\n-echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')\" | python manage.py shell\r\n+\r\n+python manage.py shell --plain &lt;&lt; END\r\n+from django.contrib.auth.models import User\r\n+if not User.objects.filter(username='${SUPERUSER_NAME}'):\r\n+    User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')\r\n+END<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#01 django.db.utils.Integ&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[173,140],"_links":{"self":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/812"}],"collection":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=812"}],"version-history":[{"count":2,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/812\/revisions"}],"predecessor-version":[{"id":814,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/812\/revisions\/814"}],"wp:attachment":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=812"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=812"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}