Hi All, I installed docker via docker compose and ...
# fleet
i
Hi All, I installed docker via docker compose and it assigns me virtual ip's to mysql and fleet(127.20.0.1 and 127.20.0. 2) fleet gui i can reach it from outside because it automatically mapped it most likely, instead as for mysql i can't connect remotely via phpmyadmin, can you tell me how to edit the compose file or how to map the ip 127.20.0.2 to the ip of host 10.0.0.2 so i can connect remotely? currently if from the host where docker is installed i do mysql root@localhost or root@10.0.0.2 it won't connect if i do instead mysql root@127.20.0.2 it works and i can reach it, who can help me? Docker compose:
Copy code
version: '2'
services:
  mysql:
    restart: always
    image: mysql:5.7
    volumes:
      - /fleet/data:/data
    command: mysqld --datadir=/data/mysqldata --slow_query_log=0 --log_output=TABLE --log-queries-not-using-indexes --event-scheduler=ON
    environment:
      MYSQL_ROOT_PASSWORD: *****************
      MYSQL_DATABASE: fleet_db
      MYSQL_USER: fleet_user
      MYSQL_PASSWORD: ************************
    ports:
      - "3306:3306"

  mailhog:
    restart: always
    image: mailhog/mailhog:latest
    ports:
      - "8025:8025"
      - "1025:1025"

  redis:
    restart: always
    image: redis:5
    ports:
      - "6379:6379"

  fleet:
    restart: always
    image: fleetdm/fleet:v4.17.0
    volumes:
      - /fleet/fleet:/fleet
    command: sh -c "echo '\n' | /usr/bin/fleet prepare db && /usr/bin/fleet serve"
    environment:
      FLEET_MYSQL_ADDRESS: mysql:3306
      FLEET_MYSQL_DATABASE: fleet_db
      FLEET_MYSQL_USERNAME: fleet_user
      FLEET_MYSQL_PASSWORD: *****************
      FLEET_REDIS_ADDRESS: redis:6379
      FLEET_SERVER_CERT: /etc/letsencrypt/live/it-asset.acme.it/fullchain.pem
      FLEET_SERVER_KEY: /etc/letsencrypt/live/it-asset.acme.it/privkey.pem
      FLEET_LOGGING_JSON: "true"
      FLEET_AUTH_JWT_KEY:
      FLEET_SERVER_TLS: 'false'
      FLEET_OSQUERY_LABEL_UPDATE_INTERVAL: 5m
      FLEET_VULNERABILITIES_PERIODICITY: 60m
    ports:
      - "8443:8080"
s
Hey @Ibra I think you can do just:
Copy code
ports:
      - ""127.20.0.2:3306:3306"
In the mysql section, according to docker-compose docs..
i
hi @sharvil i need to reach it host ip 10.0.0.2 and not on docker ip 127.20.0.2
I tried to do:
Copy code
ports:
      - "10.0.0.2:3306:3306"
and this is what appears to me:
Copy code
docker inspect fleet-mysql-1

            "NetworkMode": "fleet_default",
            "PortBindings": {
                "3306/tcp": [
                    {
                        "HostIp": "10.0.0.2",
                        "HostPort": "3306"
                    }
                ]
            },
Copy code
mysql root@10.0.0.2 -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@itl-cslapp-54 fleet]#
@sharvil
s
hrm, i am not sure, I will try to search around
i
Thanks @sharvil let me know
k
What happens with
mysql -uroot -p -h10.0.0.2 -P3306
?
b
Maybe try network mode host on the fleet service. https://docs.docker.com/network/host/