Can you trap the ender dragon?

Here are some options and some considerations:

  • You can build in the end while the Dragon is still alive as long as you build far enough from the main island.
  • Alternatively, you can lead the dragon far away from the main island and store the dragon in unloaded chunks. Then you can build at the main island at will. Just make sure no one walks in the direction of the dragon, because it will be loaded again and it will escape (it'll make its way back to the main island).
  • Putting your base at The End without killing the dragon is not very practical, because you have to kill yourself to go back.
  • You can actually trap a dying dragon with pistons that constantly move (on a clock). It is very hard to do that for alive dragon, though (especially in survival).
  • Here is a very cool video showing how to build a dragon XP farm. It also shows how to temporary store the dragon in far-away chunks, and the 'trap with pistons' trick:

Wiki for minecraft says:

They swoop at the player, destroying any blocks it passes through except obsidian, bedrock, or End Stone.

meaning that there is no material to effectively trap the dragon.