This guide walks you through building, pushing, deploying, updating, and cleaning up a Dockerized CTFd instance on Azure using Azure Container Instances.
- Build your Docker image locally:
docker build -t ctfd:latest . - Tag your image for Docker Hub:
docker tag ctfd:latest <your-dockerhub-username>/ctfd:latest
- Login to Docker Hub:
docker login
- Push your image:
docker push <your-dockerhub-username>/ctfd:latest
- Open Azure Cloud Shell (or use Azure CLI locally).
- Create a resource group (choose a supported region, e.g., centralindia):
az group create --name ctfd-test-rg --location centralindia
- Deploy your container (expose the correct port, e.g., 8000):
az container create \ --resource-group ctfd-test-rg \ --name ctfd-test \ --image <your-dockerhub-username>/ctfd:latest \ --ports 8000 \ --dns-name-label ctfdtest$RANDOM \ --location centralindia \ --os-type Linux \ --cpu 1 \ --memory 1.5
- Get the public FQDN:
az container show --resource-group ctfd-test-rg --name ctfd-test --query ipAddress.fqdn -o tsv
- Open in your browser:
http://<fqdn>:8000
- Edit your files locally, rebuild, push, and redeploy as above.
- To update the CTFd URL or admin token inside the container (if needed):
az container exec --resource-group ctfd-test-rg --name ctfd-test --exec-command "/bin/sh" sed -i 's|CTFd_URL = ".*"|CTFd_URL = "http://<fqdn>:8000/"|' import_challenges.py sed -i 's|ADMIN_TOKEN = ".*"|ADMIN_TOKEN = "<your_new_token>"|' import_challenges.py
- To run a script (e.g., import_challenges.py):
az container exec --resource-group ctfd-test-rg --name ctfd-test --exec-command "python import_challenges.py"
az container logs --resource-group ctfd-test-rg --name ctfd-test- Restart:
az container restart --resource-group ctfd-test-rg --name ctfd-test
- Delete (stop):
az container delete --resource-group ctfd-test-rg --name ctfd-test --yes
- Delete the resource group (removes all resources):
az group delete --name ctfd-test-rg --yes --no-wait
- Always use the correct port (default CTFd is 8000).
- If you need to edit files, do so locally and redeploy for best results.
- For persistent SSH or advanced features, consider Azure Web App for Containers or a VM.
Replace placeholders like <your-dockerhub-username>, <fqdn>, and <your_new_token> with your actual values.