Michael Arciniega
asked on
Port forwarding between containers in Docker Compose file
I'm not too familiar with Docker or networking in general so I'm getting confused as to whats going on in my Docker Compose file below.
1. Would each of the services be available to the host machine at something like http://localhost:4200 ?
2. If the answer is yes above, how would I ensure that the correct ports are exposed between containers but not accessible to the host machine? Does it involve defining a network instead of relying on the default one?
1. Would each of the services be available to the host machine at something like http://localhost:4200 ?
2. If the answer is yes above, how would I ensure that the correct ports are exposed between containers but not accessible to the host machine? Does it involve defining a network instead of relying on the default one?
version: '3' # specify docker-compose version
# Define the services/containers to be run
services:
angular: # name of the first service
build: ./Coding/DeepLearning/GardenApp/client-app-dev # specify the directory of the Dockerfile
ports:
- "4200:4200"
volumes:
- ./Coding/DeepLearning/GardenApp/client-app:/usr/src/garden-app-dev
express-ts: #name of the second service
build: express-ts-server # specify the directory of the Dockerfile
ports:
- "3000:3000"
links:
- database # link this service to the database service
volumes:
- ./Coding/DeepLearning/GardenApp/express-ts-server:/usr/src/express-ts-app
database: # name of the third service
image: mongo # specify image to build container from
ports:
- "27017:27017"
volumes:
- ./Coding/DeepLearning/GardenApp/database:/data/db
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I am following up on your question. Do you still need help?
If you solved the problem on your own, would you please post the solution here in case others have the same problem?
Regards,
Kyle Santos
Customer Relations