We must individually understand what happens when Deploy, Query, and Invoke is used in Hyperledger.
Deploy: Over here, the chaincode is submitted to the ledger as a transaction and distributed across all networks in the distributed blockchain network. Upon deploy, each node individually creates a new Docker Container and embeds the chain code within the Docker Container. Moving ahead, each container will start and the Init method will be executed.
Query: During a query, the current state of the chain code is sent back to the user and the transaction is not saved.
Invoke: When invoked, chain code can actually change or modify the state of variables in the distributed ledger. Transactions get added to blocks in the ledger.