How do I allow multiple keys to unlock a container block?

Solution 1:

Not directly! The Lock tag only accepts one item name. You could have multiple items with the same name instead.

But what you could do is repeatedly test if there is a player near the chest, and if they have an acceptable key, update the chest's Lock tag to match the name of the acceptable item.

For example, let's have our keys named AliceKey and BobKey, given to players Alice and Bob respectively. Summon an invisible armour stand on the chest with the tag chestKeys, then create separate command chains for each possible key:

Rpt: /execute @e[tag=chestKeys] ~ ~ ~ testfor @p {Inventory:[{tag:{display:{Name:"AliceKey"}}}]}
Cnd: /blockdata 12 23 34 {Lock:"AliceKey"}

1.13+

Command syntax was heavily changed in 1.13, and so the commands above won't work. Instead, use the new versions of /execute and /blockdata:

Rpt: /execute at @e[tag=chestKeys] if entity @p[nbt={Inventory:{tag:{display:{Name:'{"text":"AliceKey"}'}}}}] run data merge block 12 23 34 {Lock:"AliceKey"}