Docker-compose keyrock mysql subnet configuration

333 views Asked by At

I have created a docker-compose file in order to deploy my FIWARE stack. That stack includes keyrock and a Mysql BD that are connected using the following subnet:

networks:
    default:
        ipam:
            config:
                - subnet: 172.18.1.0/24

I have created that subnet due to in keyrock documentation says that keyrock use the following ip: 172.18.1.5

I would like to change that keyrock IP and also change the subnet. How can I change the subnet? If I change the subnet and the keyrock and mysql defaul IP's there is no connection between them.

1

There are 1 answers

4
Jason Fox On

Presumably the documentation you are referring to is the sample docker-compose.yml file.

keyrock:
    image: fiware/idm:7.8.0
    container_name: fiware-keyrock
    hostname: keyrock
    networks:
      default:
        ipv4_address: 172.18.1.5

This defines an I.P. Address for keyrock (172.18.1.5) which is acceptable to the MySQL Database.

mysql-db:
    restart: always
    image: mysql:5.7
    hostname: mysql-db
...
    environment:
      - "MYSQL_ROOT_HOST=172.18.1.5"

The MySQL 5.7 documentation states:

MYSQL_ROOT_HOST: By default, MySQL creates the root'@'localhost account. This account can only be connected to from inside the container as described in Connecting to MySQL Server from within the Container. To allow root connections from other hosts, set this environment variable. For example, the value 172.17.0.1, which is the default Docker gateway IP, allows connections from the host machine that runs the container. The option accepts only one entry, but wildcards are allowed (for example, MYSQL_ROOT_HOST=172.*.*.* or MYSQL_ROOT_HOST=%)

You can amend the I.P. Address and range to values of your own choosing, provided you also keep the docker ENV variable in line as well.