Mysql starts properly, i am trying to use consul connect then connect to mysql db from wordpress
job "wordpress-mysql-sample" {
datacenters = ["dc1"]
group "mysql" {
network {
mode = "bridge"
port "db" {
to = 3306
}
}
service {
name = "mysql"
port = "db"
connect {
sidecar_service {}
}
}
task "mysql" {
driver = "docker"
config {
image = "mysql:latest"
}
env {
MYSQL_ROOT_PASSWORD = "rootpassword"
MYSQL_DATABASE = "mydatabase"
MYSQL_USER = "myuser"
MYSQL_PASSWORD = "mypassword"
}
resources {
cpu = 2300
memory = 4096
}
}
}
group "wordpress" {
count = 1
network {
mode = "bridge"
port "http" {
to = 80
}
}
service {
name = "wordpress"
port = "http"
connect {
sidecar_service {
proxy {
upstreams {
destination_name = "mysql"
local_bind_port = 3306
}
}
}
}
check {
type = "http"
path = "/"
interval = "10s"
timeout = "2s"
}
}
task "wordpress" {
driver = "docker"
config {
image = "wordpress:latest"
}
env {
WORDPRESS_DB_HOST = "mysql.service.consul:3306"
WORDPRESS_DB_USER = "myuser"
WORDPRESS_DB_PASSWORD = "mypassword"
WORDPRESS_DB_NAME = "mydatabase"
}
resources {
cpu = 500
memory = 256
}
}
}
}