需要的ingress网络映射,还是host宿主机端口映射:

https://docs.docker.com/compose/compose-file/#secrets

========================

docker service create --name web \
--publish mode=host,published=80,target=80 \
nginx

==========================

ports

Expose ports.

SHORT SYNTAX

Either specify both ports (HOST:CONTAINER), or just the container port (a random host port will be chosen).

Note: When mapping ports in the HOST:CONTAINER format, you may experience erroneous results when using a container port lower than 60, because YAML will parse numbers in the format xx:yy as sexagesimal (base 60). For this reason, we recommend always explicitly specifying your port mappings as strings.

ports:
 - "3000"
 - "3000-3005"
 - "8000:8000"
 - "9090-9091:8080-8081"
 - "49100:22"
 - "127.0.0.1:8001:8001"
 - "127.0.0.1:5000-5010:5000-5010"
 - "6060:6060/udp"

LONG SYNTAX

The long form syntax allows the configuration of additional fields that can’t be expressed in the short form.

  • target: the port inside the container
  • published: the publicly exposed port
  • protocol: the port protocol (tcp or udp)
  • modehost for publishing a host port on each node, or ingress for a swarm mode port which will be load balanced.
ports:
  - target: 80
    published: 8080
    protocol: tcp
    mode: host

Note: The long syntax is new in v3.2

官方文档,才是正途-docker-compose的更多相关文章

  1. Adaptive AUTOSAR 学习笔记 2 - 官方文档下载及阅读建议

    目前互联网上没有太多的 Adaptive AUTOSAR 的学习资料,官方文档是一个很不错的途径.看过官方文档才发现,目前很多关于 Adaptive AUTOSAR 的文章都是官方文档的简化翻译,不如 ...

  2. 读vue-cli3 官方文档的一些学习记录

    原来一直以为vue@cli3 就是创建模板的工具,读了官方文档才知道原来这么有用,不少配置让我长见识了 Prefetch 懒加载配置 懒加载相信大家都是知道的,使用Import() 语法就可以在需要的 ...

  3. 【Docker官方文档】理解Docker

    本文来自Docker的官方文档,详细介绍了Docker的体系结构.重要概念.内部工作机理等内容,推荐不了解Docker内部原理的同学阅读. 什么是Docker? Docker是一个用于开发.交付和运行 ...

  4. 官方文档采用Docker方式安装

    官方文档地址:https://github.com/grafana/loki/tree/master/production The Docker images for Loki and Promtai ...

  5. postman传json串,以及postman官方文档

    最近在调试接口遇到一个问题.就是post接口传的body是一个json串. 刚开始还不知道,百度了一下才知道,其实很简单,就是在raw里面选择json.我的天如此简单的内容,而且支持html. 于是读 ...

  6. CentOS7.3利用kubeadm安装kubernetes1.7.3完整版(官方文档填坑篇)

    安装前记: 近来容器对企业来说已经不是什么陌生的概念,Kubernetes作为Google开源的容器运行平台,受到了大家的热捧.搭建一套完整的kubernetes平台,也成为试用这套平台必须迈过的坎儿 ...

  7. HBase官方文档

    HBase官方文档 目录 序 1. 入门 1.1. 介绍 1.2. 快速开始 2. Apache HBase (TM)配置 2.1. 基础条件 2.2. HBase 运行模式: 独立和分布式 2.3. ...

  8. Akka Typed 官方文档之随手记

    ️ 引言 近两年,一直在折腾用FP与OO共存的编程语言Scala,采取以函数式编程为主的方式,结合TDD和BDD的手段,采用Domain Driven Design的方法学,去构造DDDD应用(Dom ...

  9. Lagom 官方文档之随手记

    引言 Lagom是出品Akka的Lightbend公司推出的一个微服务框架,目前最新版本为1.6.2.Lagom一词出自瑞典语,意为"适量". https://www.lagomf ...

  10. 一起学微软Power BI系列-官方文档-入门指南(4)Power BI的可视化

    在前面的系列文章中,我们介绍了官方有关获取数据,以及建模的原始文档和基本介绍.今天继续给大家介绍官方文档中,有关可视化的内容.实际上获获取数据和建模更注重业务关系的处理,而可视化则关注对数据的解读.这 ...

随机推荐

  1. application/x-www-form-urlencoded从前端到后台

    html <form id="userForm1" enctype="application/x-www-form-urlencoded" method= ...

  2. JavaScript获取访问设备信息

    <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>JavaScript获取访问设备信息</tit ...

  3. CLion 终于支持 jump outside closing bracket/quote with Tab 了!

    我觉得这个 feature 真的很有用.一直期待 CLion 加上这个 feature.今天才知道最新版本(CLion 2018.3.4)中已经有这个功能了,不过我不清楚从哪个版本开始支持的. How ...

  4. git clone 出错 fatal: pack has bad object at offset 26060927: inflate returned -3

    $ git clone http://xxx.xxx.cn/liyafei/developer.gitCloning into 'developer'...remote: Counting objec ...

  5. init_connect基本用法

    服务器为每个连接的客户端执行的字符串.字符串由一个或多个SQL语句组成.要想指定多个语句,用分号间隔开.例如,每个客户端开始时默认启用autocommit模式.没有全局服务器变量可以规定autocom ...

  6. Sqlserver面试题

    1.用一条SQL语句 查询出每门课都大于80分的学生姓名 name   kecheng   fenshu 张三     语文       81张三     数学       75李四     语文   ...

  7. javascript继承有5种实现方式

    1.对象冒充 function Parent(username){ this.username = username; this.hello = function(){ alert(this.user ...

  8. HDU 2105 The Center of Gravity (数学)

    题目链接 Problem Description Everyone know the story that how Newton discovered the Universal Gravitatio ...

  9. bzoj 1088 DP

    我们可以用w[i][s]来表示到第i位的方案,s代表第i位和第i+1位是否有雷的二进制串,那么我们就可以根据每一位的雷的数量转移了. /******************************** ...

  10. 利用os、hash模块生成目录下所有文件的md5

    hashlib用于对字符串或者文件进行加密. 使用方法1: hashlib.md5('str').hexdigest() 使用MD5对str进行加密,使用hexdigest(),16进制的方式打印   ...