github:https://github.com/containrrr/watchtower
    文档:https://containrrr.dev/watchtower/
    Watchtower 是一个可以实现自动更新 Docker 基础镜像与容器的实用工具。
    它会拉取最新镜像并使用最初部署时相同的参数重新启动相应的容器。

    1. # --cleanup 每次更新都会把旧的镜像清理掉
    2. # -i --interval 更新间隔,默认300s
    3. docker run -d \
    4. --name watchtower \
    5. -v /var/run/docker.sock:/var/run/docker.sock \
    6. containrrr/watchtower \
    7. --cleanup \
    8. -i 30 \
    9. my-image

    helper

    1. docker run --rm containrrr/watchtower -h
    2. Usage:
    3. watchtower [flags]
    4. Flags:
    5. -a, --api-version string api version to use by docker client (default "1.25")
    6. -c, --cleanup remove previously used images after updating
    7. -d, --debug enable debug mode with verbose logging
    8. --enable-lifecycle-hooks Enable the execution of commands triggered by pre- and post-update lifecycle hooks
    9. -h, --help help for watchtower
    10. -H, --host string daemon socket to connect to (default "unix:///var/run/docker.sock")
    11. --http-api-metrics Runs Watchtower with the Prometheus metrics API enabled
    12. --http-api-token string Sets an authentication token to HTTP API requests.
    13. --http-api-update Runs Watchtower in HTTP API mode, so that image updates must to be triggered by a request
    14. --include-restarting Will also include restarting containers
    15. -S, --include-stopped Will also include created and exited containers
    16. -i, --interval int poll interval (in seconds) (default 86400)
    17. -e, --label-enable watch containers where the com.centurylinklabs.watchtower.enable label is true
    18. -m, --monitor-only Will only monitor for new images, not update the containers
    19. --no-color Disable ANSI color escape codes in log output
    20. --no-pull do not pull any new images
    21. --no-restart do not restart any containers
    22. --no-startup-message Prevents watchtower from sending a startup message
    23. --notification-email-delay int Delay before sending notifications, expressed in seconds
    24. --notification-email-from string Address to send notification emails from
    25. --notification-email-server string SMTP server to send notification emails through
    26. --notification-email-server-password string SMTP server password for sending notifications
    27. --notification-email-server-port int SMTP server port to send notification emails through (default 25)
    28. --notification-email-server-tls-skip-verify Controls whether watchtower verifies the SMTP server's certificate chain and host name.
    29. Should only be used for testing.
    30. --notification-email-server-user string SMTP server user for sending notifications
    31. --notification-email-subjecttag string Subject prefix tag for notifications via mail
    32. --notification-email-to string Address to send notification emails to
    33. --notification-gotify-tls-skip-verify Controls whether watchtower verifies the Gotify server's certificate chain and host name.
    34. Should only be used for testing.
    35. --notification-gotify-token string The Gotify Application required to query the Gotify API
    36. --notification-gotify-url string The Gotify URL to send notifications to
    37. --notification-msteams-data The MSTeams notifier will try to extract log entry fields as MSTeams message facts
    38. --notification-msteams-hook string The MSTeams WebHook URL to send notifications to
    39. --notification-slack-channel string A string which overrides the webhook's default channel. Example: #my-custom-channel
    40. --notification-slack-hook-url string The Slack Hook URL to send notifications to
    41. --notification-slack-icon-emoji string An emoji code string to use in place of the default icon
    42. --notification-slack-icon-url string An icon image URL string to use in place of the default icon
    43. --notification-slack-identifier string A string which will be used to identify the messages coming from this watchtower instance (default "watchtower")
    44. --notification-template string The shoutrrr text/template for the messages
    45. --notification-url stringArray The shoutrrr URL to send notifications to
    46. -n, --notifications strings notification types to send (valid: email, slack, msteams, gotify, shoutrrr)
    47. --notifications-level string The log level used for sending notifications. Possible values: panic, fatal, error, warn, info or debug (default "info")
    48. --remove-volumes remove attached volumes before updating
    49. --revive-stopped Will also start stopped containers that were updated, if include-stopped is active
    50. --rolling-restart Restart containers one at a time
    51. -R, --run-once Run once now and exit
    52. -s, --schedule string the cron expression which defines when to update
    53. --scope string Defines a monitoring scope for the Watchtower instance.
    54. -t, --stop-timeout duration timeout before a container is forcefully stopped (default 10s)
    55. -v, --tlsverify use TLS and verify the remote
    56. --trace enable trace mode with very verbose logging - caution, exposes credentials
    57. --warn-on-head-failure string When to warn about HEAD pull requests failing. Possible values: always, auto or never

    安装 mysql
    mysql:
    数据存储位置:/var/lib/mysql

    • MYSQL_ROOT_PASSWORD:密码
    • MYSQL_DATABASE: 创建数据库
    • MYSQL_ALLOW_EMPTY_PASSWORD:允许空密码

    构建wordpress:

    1. docker run -d --name mysql -v mysql-data:/var/lib/mysql5.7 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wordpress mysql:5.7
    2. docker run -d --name wordpress --link mysql -e WORDPRESS_DB_HOST=mysql:3306 -p 80:80 wordpress