- When specifying ports using the long mode syntax the following error is observed:
# docker stack deploy -c docker-compose.yml example services.web.ports.0 must be a string or number
- I am unable to configure host mode networking in a compose file, ingress is always set as the
docker stack deploy.
This issue effects the Docker Engine in Docker EE 17.03 and lower.
If you are interested in configuring a different networking mode, do note that there is currently no way to specify networking modes in a Docker Compose v3 file. The only way to specify host mode networking is to utilize compose v3.2, which is only supported in Docker Engine 17.04 and higher.
If you are running Docker Engine 17.04 or higher, ensure you've configured the
version: section of the compose file to:
- Use short mode syntax in compose files for port declaration, for example:
services: nginx: image: nginx:latest deploy: replicas: 1 placement: constraints: [node.role == worker] ports: - target: 80 published: 8001 protocol: tcp networks: - nginx_frontend networks: nginx_frontend:
services: nginx: image: nginx:latest deploy: replicas: 1 placement: constraints: [node.role == worker] ports: - "8001:80" networks: - nginx_frontend
- If you are attempting to configure a specific networking mode, such as host mode, you will need to use the
docker service updatecommand following deployment to perform the port declaration. For example, after deploying a web service where the target port is 80 and the published port is 8001, the syntax to update the mode from the default of ingress to host mode would be:
docker service update example_web --publish-rm 8001:80 --publish-add "mode=host,target=80,published=8001"