1.停止并删除halo1.4.2版本的容器
docker stop halo
docker rm -f halo
你的容器名称不一定为 halo,在执行前可以先执行 docker ps -a 查看一下。
2.拉取最新的 Halo 镜像
docker pull halohub/halo
从 1.4.3 开始,Docker 镜像已经转移到 halohub 组织,不再是 ruibaby/halo
3.运行容器
docker run -it -d --name halo -p 8090:8090 -v ~/.halo:/root/.halo --restart=always halohub/halo
- -it: 开启输入功能并连接伪终端
- -d: 后台运行容器
- –name: 为容器指定一个名称
- -p: 端口映射,格式为 主机(宿主)端口:容器端口 ,可在 application.yaml 配置。
- -v: 工作目录映射。形式为:-v 宿主机路径:/root/.halo,后者不能修改。
- –restart: 建议设置为 always,在 Docker 启动的时候自动启动 Halo 容器。
4.成功
[root@aliyun ~]# docker logs -f halo
__ __ __
/ / / /___ _/ /___
/ /_/ / __ `/ / __ \
/ __ / /_/ / / /_/ /
/_/ /_/\__,_/_/\____/
Version: 1.4.3
2021-01-30 17:06:47.077 INFO 8 --- [ main] run.halo.app.Application : Starting Application v1.4.3 using Java 11.0.9.1 on 457b388b97e4 with PID 8 (/application/BOOT-INF/classes started by root in /application)
2021-01-30 17:06:47.101 INFO 8 --- [ main] run.halo.app.Application : No active profile set, falling back to default profiles: default
2021-01-30 17:06:49.006 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-01-30 17:06:49.173 INFO 8 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 155 ms. Found 22 JPA repository interfaces.
2021-01-30 17:06:50.651 INFO 8 --- [ main] org.eclipse.jetty.util.log : Logging initialized @5201ms to org.eclipse.jetty.util.log.Slf4jLog
2021-01-30 17:06:51.018 INFO 8 --- [ main] o.s.b.w.e.j.JettyServletWebServerFactory : Server initialized with port: 8090
2021-01-30 17:06:51.026 INFO 8 --- [ main] org.eclipse.jetty.server.Server : jetty-9.4.35.v20201120; built: 2020-11-20T21:17:03.964Z; git: bdc54f03a5e0a7e280fab27f55c3c75ee8da89fb; jvm 11.0.9.1+1
2021-01-30 17:06:51.070 INFO 8 --- [ main] o.e.j.s.h.ContextHandler.application : Initializing Spring embedded WebApplicationContext
2021-01-30 17:06:51.070 INFO 8 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3825 ms
2021-01-30 17:06:51.450 INFO 8 --- [ main] run.halo.app.config.HaloConfiguration : Halo cache store load impl : [class run.halo.app.cache.InMemoryCacheStore]
2021-01-30 17:06:51.879 INFO 8 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-01-30 17:06:51.945 INFO 8 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.27.Final
2021-01-30 17:06:52.126 INFO 8 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-01-30 17:06:52.268 INFO 8 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-01-30 17:06:52.601 INFO 8 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-01-30 17:06:52.642 INFO 8 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2021-01-30 17:06:54.592 INFO 8 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-01-30 17:06:54.613 INFO 8 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-01-30 17:06:55.792 INFO 8 --- [ main] org.eclipse.jetty.server.session : DefaultSessionIdManager workerName=node0
2021-01-30 17:06:55.792 INFO 8 --- [ main] org.eclipse.jetty.server.session : No SessionScavenger set, using defaults
2021-01-30 17:06:55.795 INFO 8 --- [ main] org.eclipse.jetty.server.session : node0 Scavenging every 660000ms
2021-01-30 17:06:55.805 INFO 8 --- [ main] o.e.jetty.server.handler.ContextHandler : Started o.s.b.w.e.j.JettyEmbeddedWebAppContext@1fae388c{application,/,[file:///tmp/jetty-docbase.8090.11776193117670382944/, jar:file:/application/BOOT-INF/lib/springfox-swagger-ui-3.0.0.jar!/META-INF/resources],AVAILABLE}
2021-01-30 17:06:55.807 INFO 8 --- [ main] org.eclipse.jetty.server.Server : Started @10358ms
2021-01-30 17:06:58.483 INFO 8 --- [ main] run.halo.app.handler.file.FileHandlers : Registered 9 file handler(s)
2021-01-30 17:07:00.287 INFO 8 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-30 17:07:01.100 INFO 8 --- [ main] o.s.s.c.ThreadPoolTaskScheduler : Initializing ExecutorService 'taskScheduler'
2021-01-30 17:07:01.133 INFO 8 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 4 endpoint(s) beneath base path '/api/admin/actuator'
2021-01-30 17:07:01.249 INFO 8 --- [ main] o.e.j.s.h.ContextHandler.application : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-01-30 17:07:01.249 INFO 8 --- [ main] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2021-01-30 17:07:01.253 INFO 8 --- [ main] o.s.web.servlet.DispatcherServlet : Completed initialization in 4 ms
2021-01-30 17:07:01.276 INFO 8 --- [ main] o.e.jetty.server.AbstractConnector : Started ServerConnector@6094de13{HTTP/1.1, (http/1.1)}{0.0.0.0:8090}
2021-01-30 17:07:01.282 INFO 8 --- [ main] o.s.b.web.embedded.jetty.JettyWebServer : Jetty started on port(s) 8090 (http/1.1) with context path '/'
2021-01-30 17:07:01.324 INFO 8 --- [ main] run.halo.app.Application : Started Application in 15.172 seconds (JVM running for 15.875)
2021-01-30 17:07:01.327 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Starting migrate database...
2021-01-30 17:07:01.406 INFO 8 --- [ main] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 7.5.1 by Redgate
2021-01-30 17:07:01.418 INFO 8 --- [ main] o.f.c.i.database.base.DatabaseType : Database: jdbc:h2:file:~/.halo/db/halo (H2 1.4)
2021-01-30 17:07:01.477 INFO 8 --- [ main] o.f.c.i.s.JdbcTableSchemaHistory : Repair of failed migration in Schema History table "PUBLIC"."flyway_schema_history" not necessary. No failed migration detected.
2021-01-30 17:07:01.499 INFO 8 --- [ main] o.f.core.internal.command.DbRepair : Successfully repaired schema history table "PUBLIC"."flyway_schema_history" (execution time 00:00.052s).
2021-01-30 17:07:01.503 INFO 8 --- [ main] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 7.5.1 by Redgate
2021-01-30 17:07:01.525 INFO 8 --- [ main] o.f.core.internal.command.DbValidate : Successfully validated 4 migrations (execution time 00:00.014s)
2021-01-30 17:07:01.549 INFO 8 --- [ main] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": 4
2021-01-30 17:07:01.564 INFO 8 --- [ main] o.f.core.internal.command.DbMigrate : Schema "PUBLIC" is up to date. No migration necessary.
2021-01-30 17:07:01.566 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Migrate database succeed.
2021-01-30 17:07:01.574 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Created backup directory: [/tmp/run.halo.app/halo-backup]
2021-01-30 17:07:01.574 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Created data export directory: [/tmp/run.halo.app/halo-data-export]
2021-01-30 17:07:01.731 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Halo started at https://www.test.cn
2021-01-30 17:07:01.731 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Halo admin started at https://www.test.cn/admin
2021-01-30 17:07:01.731 INFO 8 --- [ main] run.halo.app.listener.StartedListener : Halo has started successfully!
2021-01-30 17:08:51.451 WARN 8 --- [ Timer-0] run.halo.app.cache.AbstractCacheStore : Cache key: [cache_lock_login_precheck] has been expired
2021-01-30 17:08:51.454 WARN 8 --- [ Timer-0] run.halo.app.cache.AbstractCacheStore : Cache key: [cache_lock_login_auth] has been expired
可以看到配置文件信息自动更新到了容器中,升级完成!!!