Can access container form other containers but not from localhost

The question is how you connect from client to server and from server to the database. Published ports are for you, you don’t have to open any ports on server and db if you don’t need them personally. The containers are running in a temporary network and find each other with their names db, server and client. Take a look at this description.