services:
proxy:
build: ./proxy
networks:
- frontend
app:
build: ./app
networks:
- frontend
- backend
db:
image: postgres
networks:
- backend
networks:
frontend:
# Use a custom driver
driver: custom-driver-1
backend:
# Use a custom driver which takes special options
driver: custom-driver-2
driver_opts:
foo: "1"
bar: "2"
The EXPOSE instruction does not actually publish the port. It functions as a type of documentation between the person who builds the image and the person who runs the container, about which ports are intended to be published. To actually publish the port when running the container, use the -p flag on docker run to publish and map one or more ports, or the -P flag to publish all exposed ports and map them to high-order ports.
dmitryg@dg-linux:~$ docker run -d -p 8080:8080 -p 50000:50000 jenkins:2.60.3
ed9e4a15dbeb9aafa175de1fba726ab385af80824873ee1314f96449a99d800f
dmitryg@dg-linux:~$ docker exec -it ed9e /bin/bash
jenkins@ed9e4a15dbeb:/$ apt
apt apt-cache apt-cdrom apt-config apt-get apt-key apt-mark
jenkins@ed9e4a15dbeb:/$ cat /etc/debian_version
9.5
jenkins@ed9e4a15dbeb:/$