简体   繁体   English

docker 群 - 第一个 docker-compose.yml

[英]docker swarm - first docker-compose.yml

I'm trying to run my first container on docker swarm and have following issue: on swarm node it is looping - starting 1,2,3 seconds and initialising like in a loop,我正在尝试在 docker swarm 上运行我的第一个容器,并遇到以下问题:在 swarm 节点上它正在循环 - 开始 1、2、3 秒并像循环一样初始化,

I don't know if because of my docker-compose this fails - maybe I created wrong yml file.我不知道是否因为我的 docker-compose 这失败了 - 也许我创建了错误的 yml 文件。


services:
  app1:
    image: debian:latest
    #    command: sh -c 'apt update'
    #command: sh -c 'apt install ssh -y'
    deploy:
      replicas: 1
        resources:
          limits:
            cpus: '2'
            memory: 2G
          reservations:
            cpus: '2'
            memory: 2G

networks:
  net1:
    driver: overlay

The plain debian image is just going to go to an interactive session, which counts as an exit when nothing is attached.普通的 debian 图像只是将 go 转到交互式 session ,当没有附加任何内容时,这算作退出。

You need to do something like this to keep a plain linux os image alive as a service:你需要做这样的事情来保持一个普通的 linux 操作系统图像作为服务活着:


services:
  my-service:
    image: debian
    command: tail -f /dev/null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM