any idea how I could transform the volumes_from used in docker-compose in a docker swarm (service create) command ?

version: ‘2’

services:
  andreir-hypera-php:
    image: qubestash/wordpress:php-7.1.5-fpm-alpine
    container_name: andreir-hypera-php
    environment: 
      # ...
    links:
      - andreir-hypera-mysql:mysql.hypera.local
    volumes:
      - ./wp-content:/usr/src/wordpress/wp-content
  andreir-hypera-proxy:
    image: nginx:alpine
    container_name: andreir-hypera-proxy
    links:
      - andreir-hypera-php:php.hypera.local
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./.nginx/proxy.conf:/etc/nginx/conf.d/nginx-proxy.conf
      - ./.nginx/ssl:/etc/nginx/ssl
    volumes_from: 
      - andreir-hypera-php:rw

For what I’ve shown above, I’ve got so far with my code:

docker service create 
    $DOCKER_LOG_OPTIONS 
    --replicas 1 
    --mount type=mount 
    --mount type=bind,source=$WORDPRESS_HOME/wp-content,destination=/usr/src/wordpress/wp-content 
    $DOCKER_ADDITIONAL_START 
    --name andreir-hypera-php qubestash/wordpress:php-7.1.5-fpm-alpine

docker service create 
    $DOCKER_LOG_OPTIONS 
    $DOCKER_ADDITIONAL_START 
    --replicas 1 
    --mount type=bind,source=$NGINX_HOME,destination=/etc/nginx/conf.d 
    --name andreir-hypera-nginx nginx:alpine;

The domain config I’m generating with a bash script after the wordpress container is created, however I have no way of specifying the nginx service where to read the php files from.

If what I need can’t be done, could you please suggest a work around ? Please keep in mind my wordpress container has the wordpress files embeded within it so a shared volume between the two would not be the best idea (at least from my point of view).

Read more here: Docker volumes_from to Docker Swarm


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: