Home About Me

Running OneManager with Docker Compose and a Caddy Reverse Proxy

I usually prefer deploying applications with Docker Compose. It is faster and more convenient than installing everything manually, and it is also easier to manage over time than handling a standalone Docker container directly. Here is a straightforward way to get OneManager running with Docker Compose, with Caddy placed in front of it for access by domain name.

Before starting, make sure Caddy is already installed, since it will be used later as the reverse proxy.

Set up the application

Create the working directory first:

sudo mkdir /opt/onemanager && cd /opt/onemanager
sudo mkdir data && cd data

Next, create the OneManager configuration file:

sudo cat > config.php << EOF
<?php $configs = '
{
}
';
EOF

Change the file owner to www-data:

sudo chown www-data:www-data config.php

Now create the container definition. For better security, the service is not exposed for direct access through a public IP and port. Instead, it is bound to localhost and accessed through Caddy.

sudo cat > docker-compose.yaml << EOF
services:
    onemanager:
        image: zhullyb/onemanager-php:latest
        container_name: onemanager
        restart: unless-stopped
        volumes:
            - $PWD/data:/var/www/html/.data/
        ports:
            - '127.0.0.1:8016:80'
EOF

Start the container:

sudo docker compose up -d

Accessing OneManager through a domain

Edit the Caddy configuration file:

sudo nano /etc/caddy/Caadyfile

If this is your first Caddy installation, clear the file and paste in the configuration below, then adjust the values as noted in the comments before saving.

od.example.com {                 # 替换为自己的域名(请提前做好 DNS 解析)
         tls [email protected]       # 替换为你的任意邮箱
         encode gzip
         reverse_proxy localhost:8016
}

Reload Caddy so the new settings take effect:

sudo systemctl reload caddy

At that point, OneManager should be reachable through the configured domain.

Common management commands

Run the following commands in the directory that contains the compose file, which in this setup is /opt/onemanager.

  • Stop the OneManager service
  sudo docker compose stop
  • Start the OneManager service
  sudo docker compose start
  • Restart the OneManager service
  sudo docker compose restart
  • Completely remove the OneManager service and its Docker images
  sudo docker-compose down --volumes --rmi all