replica set in MongoDB using docker, primary has error and stops being primary when another member is added to the set
Your primary is trying to auto-configure itself as ee3c41ef76b2:27017 and that then resolves to the loopback (127.0.0.1) which is then not responding on the container as it expects.  Depending on what the second container does to resolve ee3c41ef76b2, and especially it it does not resolve to 172.17.0.2, it will probably not be able to talk to the primary either.

Assuming you are correct about the connectivity (and you have verified that the instances are listening on the IP and not just the loopback) then you need to override the automatic detection and be explicit when you are calling rs.initiate(), something like this:

rs.initiate(
   {
      _id: "rs0",
      version: 1,
      members: [
         { _id: 0, host : "172.17.0.2:27017" },
         { _id: 1, host : "172.17.0.4:27017" }
      ]
   }
)