port, servicePort
(OPTIONAL)
The port
exposed by a container, to be mapped to HTTP ports 80 and 443. Think of:
docker run -it -p 80:4000 -p 443:4000 ...
The following example exposes port 4000. From outside the service will be reachable at port 80 and 443:
version: "v1"
project: "my-first-project"
services:
frontend:
web:
image: yourimage
domain: "MY-DOMAIN.sloppy.zone"
port: 4000
cmd: "/app.sh"
If you are running several apps within one project, you do not need to expose ports between apps (e.g. exposing the mysql port to the apache container).
Exposing TCP ports
In case you want to connect to an app directly via TCP (not using a domain and HTTP), you initially set the service_port
to 0
:
version: "v1"
project: "my-first-project"
services:
frontend:
web:
image: yourimage
domain: "MY-DOMAIN.sloppy.zone"
port: 4000
servicePort: 0
cmd: "/app.sh"
Once deployed, this service port will be replaced with an assigned port (in the range of 32001 to 60000.
Important note: On further deployments, you'll have to replace the 0
with the generated port. If you don't replace the 0
you will receive a new port on the next deployment.
version: "v1"
project: "my-first-project"
services:
frontend:
web:
image: yourimage
domain: "MY-DOMAIN.sloppy.zone"
port: 4000
servicePort: 32543
cmd: "/app.sh"
Multiple TCP ports
Multiple TCP ports are currently not supported in our YAML specification. Please use JSON port mapping if you want to use multiple TCP ports.