Installing Halo Blog with Docker#
- Create a container
docker run \
-it -d \
--name halo \
-p 8090:8090 \
-v ~/.halo2:/root/.halo2 \
halohub/halo:2.3.0 \
--halo.external-url=http://localhost:8090/ \
--halo.security.initializer.superadminusername=admin \
--halo.security.initializer.superadminpassword=P@88w0rd
Note: This command uses the built-in H2 Database by default. To use PostgreSQL, please refer to: Deploying with Docker Compose
- -it: Enable input and connect to a pseudo terminal
- -d: Run the container in the background
- --name: Specify a name for the container
- -p: Port mapping, in the format of
host port:container port
, can be configured inapplication.yaml
. - -v: Working directory mapping. The format is:
-v host path:/root/.halo2
, the latter cannot be modified.
Additionally: Before using the command above, you need to change the http://localhost:8090/ on line 7 to your machine's IP address. If you want to change the password, it is recommended to change the password directly as well; regarding the admin username, change it if you want, or leave it as is.
Variable Explanation:
Parameter Name | Description |
---|---|
spring.r2dbc.url | Database connection address, details can be found in the Database Configuration below |
spring.r2dbc.username | Database username |
spring.r2dbc.password | Database password |
spring.sql.init.platform | Database platform name, supports postgresql , mysql , h2 , needs to correspond with SPRING_R2DBC_URL |
halo.external-url | External access link, if public access is needed, it should be configured to the actual access address |
halo.security.initializer.superadminusername | Initial super admin username |
halo.security.initializer.superadminpassword | Initial super admin password |
Database Configuration:
Connection Method | Connection Address Format | SPRING_SQL_INIT_PLATFORM |
---|---|---|
PostgreSQL | r2dbc:pool:postgresql://{HOST}:{PORT}/{DATABASE} | postgresql |
MySQL | r2dbc:pool:mysql://{HOST}:{PORT}/{DATABASE} | mysql |
H2 Database | r2dbc:h2:file:///${halo.work-dir}/db/halo-next?MODE=MySQL&DB_CLOSE_ON_EXIT=FALSE | h2 |
- Access
$HALO_EXTERNAL_URL/console/
(external access link) in your browser to enter the Halo admin panel. The admin username isadmin
, and the login password is theHALO_SECURITY_INITIALIZER_SUPERADMINPASSWORD
set above.
If you need to configure domain access, it is recommended to set up reverse proxy and domain resolution before initialization. If you cannot access via http://ip:port
, please add the running port to the security group in the server vendor's backend. If the server uses a Linux panel, please check if there are security group configurations in this Linux panel, and also add the port to the security group.
Upgrade Version#
-
Pull the new version image
docker pull halohub/halo:2.3.0
-
Stop the running container
docker stop halo docker rm halo
-
Backup data (important)
cp -r ~/.halo2 ~/halo2.archive
Note that the
halo2.archive
filename does not have to be named according to this document; it is just an example. -
Update Halo
After modifying the version number, recreate the container as initially installed.
docker run \ -it -d \ --name halo \ -p 8090:8090 \ -v ~/.halo2:/root/.halo2 \ halohub/halo:2.3.0 \ --halo.external-url=http://localhost:8090/ \ --halo.security.initializer.superadminusername=admin \ --halo.security.initializer.superadminpassword=P@88w0rd