Using SiteDrive & Docker

Docker can help maintaining multiple servers in a local environment a breeze. It can also help with testing your custom SiteDrive integration. Having said that, there are a few pitfalls to keep in mind. Let's take the following docker-compose file as our example.

version: "3"
services:
  db:
    # We use a mariadb image which supports both amd64 & arm64 architecture
    image: mariadb:10.6.4-focal
    # If you really want to use MySQL, uncomment the following line
    #image: mysql:8.0.27
    command: '--default-authentication-plugin=mysql_native_password'
    volumes:
      - ./mysql:/var/lib/mysql
      - ./mysql-log:/var/log/mysql
      #- ./config/mariadb.cnf:/etc/mysql/mariadb.cnf
    #restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=somewordpress
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
    ports:
      - 3307:3306
    expose:
      - 3307
      - 33070

  wordpress:
    hostname: wplocal
    image: wordpress:latest
    ports:
      - 8091:80
    #restart: always
    environment:
      - WORDPRESS_DB_HOST=db
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=wordpress
      - WORDPRESS_DB_NAME=wordpress
    volumes:
      - ./wordpress:/var/www/html

  db_client:
    # We use a mariadb image which supports both amd64 & arm64 architecture
    image: mariadb:10.6.4-focal
    # If you really want to use MySQL, uncomment the following line
    #image: mysql:8.0.27
    command: '--default-authentication-plugin=mysql_native_password'
    volumes:
      - ./mysql-client:/var/lib/mysql
      - ./mysql-client-log:/var/log/mysql
      #- ./config/mariadb.cnf:/etc/mysql/mariadb.cnf
    #restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=somewordpress
      - MYSQL_DATABASE=wordpress
      - MYSQL_USER=wordpress
      - MYSQL_PASSWORD=wordpress
    ports:
      - 3308:3306
    expose:
      - 3308
      - 33080

  wordpress_client:
    hostname: wplocal
    image: wordpress:latest
    ports:
      - 8092:80
    #restart: always
    environment:
      - WORDPRESS_DB_HOST=db_client
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=wordpress
      - WORDPRESS_DB_NAME=wordpress
    volumes:
      - ./wordpress-client:/var/www/html

This docker-compose setup has two main servers. wordpress and wordpress_client . They are both on the same docker network. We have exposed both sites to our 8081 port and 8082 port respectively.

SiteDrive works by having the servers themselves connect to each other. While you are able to reach http://localhost:8081 that does not mean your docker containers can. They are exposed to each other via their names.

So when we are on wordpress_client and we want to connect to the wordpress container. We will use http://wordpress as the URL for the drive connection settings.

Still need help? Contact Us Contact Us