angelo-v / wordpress-backup

Simple Docker container that helps you backup and restore your WordPress blog.
80 stars 60 forks source link

Container name reference in swarm mode #16

Closed thibaut-poullain closed 7 years ago

thibaut-poullain commented 7 years ago

Hi there,

Thx for your work :)

I try to make it works in a docker-stack.yml, but my containers names in my stack are partialy randomly created :

winter_wp.1.pexv7h9ifzr582og0jmdjq8ns

The solution, to me, is to find the way to find the variable part of the container name.

Can you help me to use your image in a swarm mode ?

thx :)

thibaut-poullain commented 7 years ago

here is my docker-stack.yml

version: "3.1"
services:
 wp:
     image: wordpress:latest
     volumes:
       - wp_content:/var/www/html/wp-content
     secrets:
       - wp_db_password
     ports:
       - 2017:80
     environment:
       - WORDPRESS_DB_USER=louwp
       - WORDPRESS_DB_NAME=louwp
       - WORDPRESS_DB_PASSWORD_FILE=/run/secrets/wp_db_password
       - WORDPRESS_DB_HOST=mariadb
     networks:
       - wp_lou
     deploy:
       placement:
           constraints: [node.role == manager]
       replicas: 1
       update_config:
         parallelism: 2
         delay: 10s
       restart_policy:
         condition: on-failure
 mariadb:
     image: mariadb
     volumes:
       - mariadb_vol:/var/lib/mysql
     secrets:
       - wp_db_password
       - root_db_password
     environment:
       - MYSQL_USER=louwp
       - MYSQL_DATABASE=louwp
       - MYSQL_PASSWORD_FILE=/run/secrets/wp_db_password
       - MYSQL_ROOT_PASSWORD_FILE=/run/secrets/root_db_password
     networks:
       - wp_lou
     deploy:
       placement:
           constraints: [node.role == manager]
       replicas: 1
       restart_policy:
         condition: on-failure
 wp_backup:
     image: aveltens/wordpress-backup
     deploy:
       restart_policy:
           condition: on-failure
     volumes:
         xxxxxxx <---------------- to find !!!!!! :)
     environment:
      - MYSQL_ENV_MYSQL_DATABASE=louwp
      - MYSQL_ENV_MYSQL_USER=louwp
      - MYSQL_ENV_MYSQL_PASSWORD=/run/secrets/wp_db_password
      - MYSQL_PORT_3306_TCP_PORT=3306
secrets:
 wp_db_password:
   external: true
 root_db_password:
   external: true
volumes:
 wp_content:
 mariadb_vol:
networks:
 wp_lou:
   external: true
angelo-v commented 7 years ago

Hi, the random parts of the container names should not be any problem. You have to create a volume for /var/www/html and use this in "wp" as well as in "wp_backup". Further, wordpress-backup does not yet support secrets from files, so you have to set the MYSQL_ENV_MYSQL_PASSWORD to your password value unfortunately.

You can find a working example of a stack-ready docker-compose.yml in my wordpress-backup-quickstart project.