Title
#fleet
w

Willi

04/28/2021, 3:34 PM
Hi, i am workingon an docker-compose file to super fast put fleet as a docker on my hosts:
version: '3.7'
services:
fleet:
image: fleetdm/fleet:latest
container_name: fleet
depends_on:
- db
- redis
secrets:
- db-password
- server-certificate
- server-key
- jwt-key
environment:
FLEET_MYSQL_ADDRESS: localhost:3306
FLEET_MYSQL_DATABASE: kolide
FLEET_MYSQL_USERNAME: fleet
FLEET_MYSQL_PASSWORD: 1234
FLEET_REDIS_ADDRESS: localhost:6379
FLEET_SERVER_CERT: /run/secrets/server-certificate
FLEET_SERVER_KEY: /run/secrets/server-key
FLEET_AUTH_JWT_KEY: /run/secrets/db-password
restart: always
networks:
- my_network
ports:
- "1337:1337"
command: [ "fleet", "prepare", "db"]
entrypoint:
- /usr/bin/fleet
- serve
db:
image: mysql:5.7
container_name: db
secrets:
- db-password
restart: always
volumes:
- ./db:/var/lib/mysql
environment:
MYSQL_DATABASE: kolide
MYSQL_ROOT_PASSWORD_FILE: /run/secrets/db-password
MYSQL_USER: fleet
MYSQL_PASSWORD: 1234
networks:
- my_network
ports:
- "3306:3306"
redis:
image: redis:latest
container_name: redis
restart: always
networks:
- my_network
ports:
- "6379:6379"
secrets:
db-password:
file: ./password.txt
server-certificate:
file: ./server.cert
server-key:
file: ./server.key
jwt-key:
file: ./jwt.key
networks:
my_network:
driver: bridge
but the fleet docker will not connect to the mysql instance:
fleet | mysql="could not connect to db: dial tcp 127.0.0.1:3306: connect: connection refused"
I also tried it with
mysql:8.0
but the error stays the same. I would be very thankfull for any ideas!
zwass

zwass

04/28/2021, 3:39 PM
I'm not familiar with bridge networking on Docker but you probably need a different hostname in your
FLEET_MYSQL_ADDRESS
.
Martin Pöhlmann

Martin Pöhlmann

04/28/2021, 6:06 PM
bridge is the default Docker network mode. You need to replace localhost by db, e.g.
db:3306
. The same applies to redis. There is also no need to expose the mysql and redis port to the host. I based my setup on the osquery-in-a-box repo