I would think you are looking for 'The City and the Stars' by Arthur C Clarke
The City and the Stars is a science fiction novel by British writer Arthur C. Clarke, published in 1956. This novel is a complete rewrite of his earlier Against the Fall of Night, which was Clarke's first novel, and was published in Startling Stories magazine in 1948, after John W. Campbell, Jr., editor of Astounding Science-Fiction, had rejected it, according to Clarke..
The City and the Stars takes place one billion years in the future, in the city of Diaspar. By this time, the Earth is so old that the oceans have gone and humanity has all but left. As far as the people of Diaspar know, theirs is the only city left on the planet.
The city of Diaspar is completely enclosed. Nobody has come in or left the city for as long as anybody can remember, and everybody in Diaspar has an instinctive insular conservatism. The story behind this fear of venturing outside the city tells of a race of ruthless invaders which beat humanity back from the stars to Earth, and then made a deal that humanity could live—if they never left the planet.
In Diaspar, the entire city is run by the Central Computer. Not only is the city repaired by machines, but the people themselves are created by the machines as well.
The computer creates bodies for the people of Diaspar to live in and stores their minds in its memory at the end of their lives. At any time, only a small number of these people are actually living in Diaspar; the rest are retained in the computer's memory banks.
All the currently existent people of Diaspar have had past "lives" within Diaspar except one person—Alvin, the main character of this story. He is one of only a very small number of "Uniques", different from everybody else in Diaspar, not only because he does not have any past lives to remember, but because instead of fearing the outside, he feels compelled to leave.
Alvin has just come to the age where he is considered grown up, and is putting all his energies into trying to find a way out.
Eventually, a character called Khedron the Jester helps Alvin use the central computer to find a way out of the city of Diaspar. This involves the discovery that in the remote past, Diaspar was linked to other cities by an underground transport system. This system still exists although its terminal was covered over and sealed with only a secret entrance left.