Published Sep 09, 2020
[
 
]
Ports is defined as
Exports ports. Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen)
docker-compose.yml
wil be shared amount different services started
by the docker-composedocker-compose.yml
mysql:
image: mysql:5.7
ports:
- "3306"
docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------
mysql_1 docker-entrypoint.sh mysqld Up 0.0.0.0:32769->3306/tcp
Expose is defined as
Expose ports without publishing them to the host machine - they’ll only be accessible to linked services. Only the internal port can be specified
mysql:
image: mysql:5.7
expose:
- "3306"
Name Command State Ports
---------------------------------------------------------------
mysql_1 docker-entrypoint.sh mysqld Up 3306/tcp