brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: start Portainer with --admin-password-file instead of typing the password in time

Portainer
~/tips/tip-portainer-admin-password-file

docker run -d -p 9443:9443 --name portainer \

Sets the first admin password from a file when Portainer starts, so you skip the setup page.

A fresh Portainer waits for you to open the web page and create the admin user. If you script your setup, you can set the password when you start the container instead.

Put the password in a file and pass it with --admin-password-file. The flag goes after the image name:

docker run -d -p 9443:9443 --name portainer \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v portainer_data:/data \
  -v /tmp/portainer_password:/tmp/portainer_password \
  portainer/portainer-ce:lts \
  --admin-password-file /tmp/portainer_password

Create the file with echo -n mypassword > /tmp/portainer_password. The -n matters, otherwise a newline becomes part of the password. The docs say it also works with Docker secrets, where the path is /run/secrets/<name>.

The caveat: it only applies when the admin user is first created. It cannot change an existing password. If you already have an admin and forgot the password, you need the reset helper instead. And delete the plain-text file afterwards.

For a home server I find this a tidy habit. The password then sits in one place that you control, instead of in your shell history, and a rebuilt container comes up already configured. If you use Compose, the same flag goes under command: and the file under volumes:. Just keep the file readable only by you.

Further reading: CLI configuration, On this site: switch on Force HTTPS only in Portainer, but test 9443 first, On this site: reset a forgotten Portainer admin password with the helper-reset-password image

More Portainer tips Choose Polling in a Portainer GitOps update when your Git host can't reach Portainer Put Portainer environments in groups and give users access to a whole group Portainer's Edge Agent checks in every 5 seconds, and you can change that docker run -d -p 9001:9001 --name portainer_agent --restart=always \ Deploy the container → Replace All Portainer tips (28) All topics

Link