Zero-touch install / daily self-update via cron.
- Installs or updates Portainer CE to the latest
portainer/portainer-ce:latestimage - Re-creates the container only when a newer image exists
- Persists data in a named volume
portainer_data - Verifies the container is running and its HTTPS API on 9443 responds
- Self-copies to
/usr/local/sbin/portainer-auto-update.shand adds a daily 03:30 cron job - Emits clear logs; exits non-zero on any failure
curl -fsSL https://gist.githubusercontent.com/supermarsx/a8b61ab7ac05f04c5883cb8179205e77/raw/portainer-ce-auto-install-update.sh | sudo bashDownloads the raw script and runs it as root.
Safe to re-run anytime; idempotent.
# First run (installs Portainer and sets up daily cron):
sudo bash portainer-auto-update.sh
# Disable cron on this run only:
sudo portainer-auto-update.sh --no-cron
# Completely remove the cron job:
sudo portainer-auto-update.sh --remove-cron
# Override the schedule (24-h format, cron syntax):
sudo portainer-auto-update.sh --cron-schedule "15 4 * * *"| Variable | Default | What it does |
|---|---|---|
PORTAINER_IMAGE |
portainer/portainer-ce:latest |
Image to deploy |
CONTAINER_NAME |
portainer |
Container name |
DATA_VOLUME |
portainer_data |
Persistent volume for /data |
CRON_SCHEDULE |
30 3 * * * |
Daily update time |
STOP_TIMEOUT |
30 s |
Graceful stop before docker kill |
WAIT_RUNNING_TIMEOUT |
60 s |
Wait for container to reach Running |
WAIT_HTTP_TIMEOUT |
90 s |
Wait for HTTPS API on 9443 |
# Managed by portainer-auto-update.sh — do not edit by hand
30 3 * * * root /usr/local/sbin/portainer-auto-update.sh >>/var/log/portainer-auto-update.log 2>&1Logs are appended to /var/log/portainer-auto-update.log.
- Linux host with Docker Engine running
curlavailable (for HTTPS health-check)- Root privileges (
sudo) to manage Docker, volumes, and cron
| Symptom | Resolution |
|---|---|
| “Docker is not installed” error | Install Docker Engine and ensure the daemon is active. |
| Script exits at HTTPS probe | Verify port 9443 is reachable and not blocked by a firewall. |
| Cron doesn’t seem to run | Check /etc/cron.d/portainer-auto-update exists and restart cron/crond service. |