0

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.

asolleiro
  • 81
  • 5

1 Answers1

1

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.

Jason Fox
  • 5,115
  • 1
  • 15
  • 34
  • Thanks for you comment. The problem is that if I change the mysql or keyrock ip, the FIWARE component (keyrock) can't create the default configurations. However, if I use the default ip configuration, when I start the services, Keyrock automatically create a table in mysql. – asolleiro Mar 31 '20 at 14:25
  • 1
    Keyrock creates the defaults _once it successfully connects_ to a MySQL instance. If it can't connect (or MySQL won't allow it) the default user won't be created, so failure to create means you have a connection issue. The documented I.P. address isn't a requirement , it is merely a working example. You should probably post your existing docker compose and the keyrock connection log to get further advice. – Jason Fox Mar 31 '20 at 15:49
  • Ok, It works fine in local(using docker-compose). However it doesn't work using docker swarm. Could you give me an example of keyrock - mysql configuration using a docker-swarm file? – asolleiro Apr 01 '20 at 08:57
  • Sorry, could you help me? I need to deploy it using docker stack deploy. Thanks in advanced. – asolleiro Apr 24 '20 at 14:35