Docker Compose Deployment
Docker Compose deployment starts both SurveyKing and MySQL simultaneously, suitable for long-term self-hosting of the Community Edition.
Use Cases
- You have a Linux cloud server.
- The server has Docker and Docker Compose installed.
- You want to store the database, uploaded attachments, and logs in fixed directories for easy backup and migration.
If you are new to this, and already have aaPanel installed, consider Simple Deployment with aaPanel first. If you don’t want to install aaPanel, use the Docker Compose method described in this document.
Steps
1. Connect to the Server
Connect to your server using an SSH tool.
Navigate to a directory where you want to save the deployment files, for example:
cd /opt
2. Run the One-Click Script
Execute the following two commands:
curl -sSO https://surveyking.cn/surveyking-docker/setup.sh
bash setup.sh
The script creates a surveyking directory and generates a Docker Compose configuration.
If the script prompts you to choose a port, pressing Enter uses the default ports:
| Service | Default Port |
|---|---|
| SurveyKing System | 1991 |
| MySQL | 33060 |
3. Wait for Startup Completion
After execution, check the container status:
cd surveyking
docker compose ps
If surveyking-app and surveyking-mysql are both running, the service has started.
You can also view application logs:
docker compose logs -f surveyking-app
When you see Started SurveyServerApplication, SurveyKing has started successfully.
4. Open and Initialize the System
Access from the server's local machine:
http://localhost:1991
Access from other computers or mobile devices:
http://server_public_ip:1991
The first time you open it, you will automatically enter the /setup page.
Select MySQL Database, and choose Docker Compose Built-in MySQL as the deployment method. If the default values on the page are inconsistent, fill in the following:
| Configuration Item | Value |
|---|---|
| Database Address | mysql |
| Port Number | 3306 |
| Database Name | surveyking |
| Username | surveyking |
| Password | Password in surveyking/.env |
Enter 3306 for the port, not 33060. 33060 is the external access port for MySQL on the server. The SurveyKing container uses the internal port 3306 to connect to the MySQL container.
See Initialization, Backup, and Upgrade for subsequent system information, default account, and password change steps.
Common Management Commands
Execute all commands in the surveyking directory:
cd /opt/surveyking
| What You Want to Do | Command |
|---|---|
| Start Service | docker compose up -d |
| Stop Service | docker compose down |
| Restart Service | docker compose restart |
| Check Status | docker compose ps |
| View SurveyKing Logs | docker compose logs -f surveyking-app |
| View MySQL Logs | docker compose logs -f surveyking-mysql |
Changing Ports
If 1991 is in use, you can specify a new port before running the script:
SK_APP_PORT=8080 bash setup.sh
If 33060 is in use, you can specify the external MySQL port:
SK_MYSQL_PORT=33061 bash setup.sh
After changing the port to 8080, change the access address to http://server_public_ip:8080.
Viewing MySQL Password
The script automatically generates a MySQL password and writes it to surveyking/.env. You also need to use this password when selecting MySQL in the /setup for the first time.
View the password:
cd /opt/surveyking
cat .env
You will see something like:
MYSQL_PASSWORD=a_random_password
Backup, Restore, and Upgrade
See Initialization, Backup, and Upgrade for daily backup, import/restore, and upgrade steps.
If you only want to update the Docker image in place, export a backup first, then execute:
cd /opt/surveyking
docker compose pull
docker compose up -d
docker image prune -f
Common Issues
Why does the MySQL port need to be 3306 in /setup, but the script's default port is 33060?
33060 is the port used for external connections to MySQL.
The SurveyKing application and MySQL are both within the Docker Compose internal network, so SurveyKing connects to MySQL using the container’s internal address, hence /setup requires:
mysql:3306
Do not enter 33060 in /setup.
Why can't my mobile device access localhost:1991?
localhost only represents the current device. The localhost on a mobile device is the mobile device itself, not the server.
To access the server from a mobile device, enter:
http://server_public_ip:1991
If it doesn't open, check two things:
- Whether the cloud server’s security group allows port
1991. - Whether the server’s system firewall allows port
1991.
What should I do if a port is occupied?
If application port 1991 is in use, change it to 8080:
SK_APP_PORT=8080 bash setup.sh
If MySQL external port 33060 is in use, change it to 33061:
SK_MYSQL_PORT=33061 bash setup.sh
What should I do if the service fails to start?
First check the container status:
cd /opt/surveyking
docker compose ps
Then view the logs:
docker compose logs surveyking-app
docker compose logs surveyking-mysql
Common causes are port conflicts, Docker not starting, the server failing to download images, or a failed SQL initialization.
Will resetting the service delete data?
The following command will delete the MySQL data volume; do not execute it lightly:
docker compose down -v
If you only want to stop the service, use:
docker compose down