Deploy Community Edition with Docker
Docker deployment is suitable for users who already have Docker installed. This allows you to start SurveyKing v1.12.0 with a single command.
Use Cases
- You are comfortable using the terminal and your computer or server has Docker installed.
- You want to quickly try it out using the embedded H2 database.
- You have your own MySQL instance and want to connect SurveyKing to an existing database.
If you plan to use it on a server for extended periods and haven't prepared a MySQL instance, we recommend Docker Compose Deployment. It deploys both SurveyKing and MySQL simultaneously.
Steps
1. Create Data Directories
First, create a directory to store data:
mkdir -p surveyking/db surveyking/files surveyking/logs
cd surveyking
These directories store the database files, uploaded attachments, and running logs, respectively.
2. Start SurveyKing
Run the following command:
docker run -d \
--name surveyking \
--restart unless-stopped \
-p 1991:1991 \
-v "$PWD/db:/app/db" \
-v "$PWD/files:/app/files" \
-v "$PWD/logs:/app/logs" \
surveyking/surveyking:latest
If you are in China and experience slow downloads from Docker Hub, use the Alibaba Cloud mirror instead:
docker run -d \
--name surveyking \
--restart unless-stopped \
-p 1991:1991 \
-v "$PWD/db:/app/db" \
-v "$PWD/files:/app/files" \
-v "$PWD/logs:/app/logs" \
registry.cn-hangzhou.aliyuncs.com/surveyking/surveyking:latest
After starting, use the following command to view logs:
docker logs -f surveyking
Once you see Started SurveyServerApplication, the startup was successful.
3. Open and Initialize the System
Access via browser:
http://localhost:1991
The first time you open it, you will automatically enter the /setup page.
If you are just trying it out, select H2 embedded database. See Initialization, Backup, and Upgrade for complete initialization steps.
If you want to connect to an external MySQL instance, we recommend using Docker Compose Deployment. Single container Docker is more suitable for H2 testing.
After initialization, log in with the default account as described in Initialization, Backup, and Upgrade and immediately change your password.
4. Manage Services
Common commands:
| Action | Command |
|---|---|
| Stop the service | docker stop surveyking |
| Start the service | docker start surveyking |
| Restart the service | docker restart surveyking |
| View logs | docker logs -f surveyking |
| Check container status | docker ps |
Using a MySQL Database
If you already have MySQL, you can connect the Docker container to an external MySQL instance.
First, create an empty database in MySQL; manual import of the initialization script is not required:
CREATE DATABASE surveyking DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
Then start SurveyKing:
docker run -d \
--name surveyking \
--restart unless-stopped \
-p 1991:1991 \
-v "$PWD/files:/app/files" \
-v "$PWD/logs:/app/logs" \
-e PROFILE=mysql \
-e MYSQL_USER=surveyking \
-e MYSQL_PASS=your_database_password \
-e DB_URL='jdbc:mysql://database_ip:3306/surveyking?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai' \
surveyking/surveyking:latest
Replace the following configurations:
| Configuration | Value |
|---|---|
database IP | IP address of your MySQL server |
surveyking | Your database name |
MYSQL_USER | MySQL username |
MYSQL_PASS | MySQL password |
If MySQL is running on the Docker host, localhost inside the container does not refer to the host. A common Linux notation is 172.17.0.1. Using the server's internal IP address is more reliable.
After starting, you will again enter /setup for the first access. Select MySQL database and enter connection information as described in Initialization, Backup, and Upgrade.
Backup and Upgrade
See Initialization, Backup, and Upgrade for unified backup, restore, and upgrade steps.
Before deleting the container, ensure that the db, files, and logs mounted directories still exist. Do not delete the data directory.
Common Issues
Why do I enter /setup instead of the login page?
This is the initial setup page for v1.12.0. The system needs to confirm whether you are using H2 or MySQL.
Complete initialization as described in Initialization, Backup, and Upgrade, then access http://localhost:1991 to enter the login page.
Why can't my mobile device open localhost:1991?
localhost only refers to the current device. To access from a mobile device, you need to use the local network IP address of the computer running SurveyKing, for example:
http://192.168.1.23:1991
If SurveyKing is running on a cloud server, use the public IP address of the server:
http://server_public_ip:1991
Ensure that the server’s firewall and cloud service provider security groups allow traffic on port 1991.
What if port 1991 is already in use?
Change the following line in the command:
-p 1991:1991
to:
-p 8080:1991
Then access http://localhost:8080.
What happens if I delete the container?
Deleting the container will not lose data in the mounted directories.
Do not delete these directories:
surveyking/dbsurveyking/filessurveyking/logs
If you are using an external MySQL instance, export a system backup or back up the MySQL database separately before upgrading.
Why can't I download the image from Docker Hub?
You can use the Alibaba Cloud mirror address:
registry.cn-hangzhou.aliyuncs.com/surveyking/surveyking:latest
Replace the image name at the end of the startup command with this address.