execute a command within docker swarm service

后端 未结 11 1805
眼角桃花
眼角桃花 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:13

    You can jump in a Swarm node and list the docker containers running using:

    docker container ls
    

    That will give you the container name in a format similar to: containername.1.q5k89uctyx27zmntkcfooh68f

    You can then use the regular exec option to run commands on it:

    docker container exec -it containername.1.q5k89uctyx27zmntkcfooh68f bash
    

提交回复
热议问题