Docker Community Forums

Share and learn in the Docker community.

Can't create database in docker swarm

hello eveyrone!

I have this docker-compose.yml file

version: '3'
services:
  mysql:
    image: mariadb
    #container_name: maria_database
    restart: always
    deploy:
      placement:
        constraints: [node.labels.com.swift.keystone.db == 1]
    environment:
      MYSQL_DATABASE: 'keystone'
      # So you don't have to use root, but you can if you like
      MYSQL_USER: 'admin'
      # You can use whatever password you like
      MYSQL_PASSWORD: 'admin!!!'
      # Password for root access
      MYSQL_ROOT_PASSWORD: 'sssssssssssss.@vtzp4'
    ports:
      - '3306:3306'
    expose:
      - '3306'
    volumes:
      - /root/data/mysql:/var/lib/mysql
      - /root/data/mysql-conf:/etc/mysql/conf.d

When I use docker-compose.yml to deploy in local with out

deploy:
placement:
constraints: [node.labels.com.swift.keystone.db == 1]

In mysql, I can see keystone database,

And when I use docker stack to deploy in worker node, I don’t see keystone database or admin user