I am trying to create a docker-compose which sets up a huge environment of dockers with portainer as a manager.
The problem is that the first time the user use "docker-compose up" and the portainer start running, he has to navigate to portainer web interface (localhost:9000) and set-up the admin user and password.
How can I automate this step and create a portainer with a default user that I define so when the user navigate to portainer on the first time, the admin user is already created.
Here is my docker-compose.yml
version: '3.3'
services:
portainer:
image: portainer/portainer
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./portainer/portainer_data:/data
ports:
- "9000:9000"
Portainer allows you to specify an encrypted password from the command line for the admin account. You need to generate the hash value for password.
For example, this is the hash value of password - $$2y$$05$$arC5e4UbRPxfR68jaFnAAe1aL7C1U03pqfyQh49/9lB9lqFxLfBqS
In your docker-compose file make following modification
version: '3.3'
services:
portainer:
image: portainer/portainer
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./portainer/portainer_data:/data
command: --admin-password "$$2y$$05$$arC5e4UbRPxfR68jaFnAAe1aL7C1U03pqfyQh49/9lB9lqFxLfBqS"
ports:
- "9000:9000"
--admin-password This flag is used to specify an encrypted password in Portainer.
More information can be found in documentation - Portainer
Hope this will help you.