execute a command within docker swarm service

后端 未结 11 1796
眼角桃花
眼角桃花 2020-12-04 15:16
  1. Initialize swarm mode:

    root@ip-172-31-44-207:/home/ubuntu# docker swarm init --advertise-addr 172.31.44.207
    
    Swarm initialized: current node (4mj61o         
    
    
            
11条回答
  •  生来不讨喜
    2020-12-04 16:04

    You can execute commands by filtering container name without needing to pass the entire swarm container hash, just by the service name. Like this:

    docker exec $(docker ps -q -f name=servicename) ls

提交回复
热议问题