I am trying to set up the admin password for Portainer in the docker-compose file using a .env file. It creates the containers fine and according to the log it says the it "Created admin user with the given password". When I try to log in with the username ‘admin’ and the password which is hashed in the .env file, it says the password is wrong.
docker-compose
version: '3'
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data portainer/portainer-ce
ports:
- 9000:9000
command: --admin-password '${PORTAINER_PASSWORD}'
volumes:
portainer_data:
.env
PORTAINER_PASSWORD='$$2y$05$q8...'
Alternatively, I have also tried the second method mentioned in the docs, which is storing the password in plaintext. That plaintext file is stored in the same directory as the yaml file. I end up getting the error "failed getting admin password file: could not get the contents of the file ‘./portainer_password’"
docker-compose
version: '3'
services:
portainer:
image: portainer/portainer-ce:latest
container_name: portainer
restart: always
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data portainer/portainer-ce
ports:
- 9000:9000
command: --admin-password-file './portainer_password'
volumes:
portainer_data:
portainer_password
123456
This issue has been confusing me and I have done a fair bit of Googling and reading docs, so I appreciate all the help I can get.
2
Answers
In bash, what is between simple quotes are not evaluated. I think it s part of the issue.
Did you tried to use double quotes instead ?
You must escape all $ in the .env file with $$