Create Stack with Secrets

Assignment

  • Let's use our Drupal compose file from last assignment
  • Rename image back to official drupal:8.2

  • Remove build:

  • Add secret via external:

  • use environment variable POSTGRES_PASSWORD_FILE

  • Add secret via cli echo "<pwd" | docker secret create psql-pw -

  • Copy compose into a new yml file on your Swarm node1

Solution

docker-compose.yml

version: '3.1'

services:
  drupal:
    image: drupal:8.2
    ports:
      - "8080:80"
    volumes:
      - drupal-modules:/var/www/html/modules
      - drupal-profiles:/var/www/html/profiles
      - drupal-sites:/var/www/html/sites
      - drupal-themes:/var/www/html/themes

  postgres:
    image: postgres
    environment:
      - POSTGRES_PASSWORD_FILE=/run/secrets/psql-pw
    secrets:
      - psql-pw
    volumes:
      - drupal-data:/var/lib/postgresql/data

volumes:
  drupal-data:
  drupal-modules:
  drupal-profiles:
  drupal-sites:
  drupal-themes:

secrets:
  psql-pw:
    external: true
  • uploaded to node1 with docker-compose scp docker-compose.yml node1:
~> echo "mypassword" | docker secret create psql-pw -
ktmt4wwjkvhuoghaixoi6vv04

~> [email protected]:~$ docker stack deploy -c docker-compose.yml drupal
Creating service drupal_postgres
Creating service drupal_drupal

results matching ""

    No results matching ""