Docker群:如何手动设置节点名? [英] Docker swarm: How to manually set node names?

查看:255
本文介绍了Docker群:如何手动设置节点名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的环境的一些背景:

我有3 ubuntu 14.04流氓盒上的docker群组。群主在一台机器上运行(有领事),另外2台机器正在运行加入主机的群组工作人员。我在文档页面之后设置了环境 https://docs.docker.com/swarm/install -manual / 。它正常工作,所以从我的主机运行的任何 docker -H:4000< some_docker_command> 可以正常运行。当我在两个工作人员上运行 gliderlabs / registrator 容器时,服务发现是活跃的。对群集的任何更改(如节点或容器故障)都会在30秒左右内显示出来(这在我看来有点慢,但至少其工作)。

I have docker swarm running on 3 ubuntu 14.04 vagrant boxes. The swarm master is running on 1 machine (with consul) and the other 2 machines are running swarm workers that are joined to the master. I set up the environment following the documentation page https://docs.docker.com/swarm/install-manual/. It is working correctly so that any docker -H :4000 <some_docker_command> run from my master machine works fine. Service discovery is active as I am running the gliderlabs/registrator container on both of my workers. Any changes to my cluster, such as a node or container failure, are shown by swarm within about 30 seconds (which is a bit slow in my opinion, but at least its working).

问题:

Swarm将我的两个节点识别为ubuntu-14

Swarm recognizes both of my nodes as "ubuntu-14"

vagrant@ubuntu-14:~$ docker -H :4000 ps
CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                        NAMES
a6972155d243        cohenaj194/apache-simple   "/usr/sbin/apache2ctl"   About an hour ago   Up 13 seconds       172.28.128.6:32770->80/tcp   ubuntu-14/test2
af78a8c788ed        gliderlabs/registrator     "/bin/registrator con"   2 hours ago         Up About an hour                                 ubuntu-14/registrator2
8e39416a785a        gliderlabs/registrator     "/bin/registrator con"   2 hours ago         Up 2 hours                                       ubuntu-14/registrator1
27c2225b32fb        cohenaj194/apache-simple   "/usr/sbin/apache2ctl"   2 hours ago         Up 2 hours          172.28.128.4:32770->80/tcp   ubuntu-14/test1
vagrant@ubuntu-14:~$ docker -H :4000 network ls
NETWORK ID          NAME                DRIVER
38b24dc5615b        ubuntu-14/bridge    bridge              
c4e1ffae2fa7        ubuntu-14/bridge    bridge              
29cf499e57ab        ubuntu-14/host      host                
7b4a4a153ada        ubuntu-14/host      host                
723b6bc6f23c        ubuntu-14/none      null                
01f3647d62cd        ubuntu-14/none      null   

我想知道如何手动将节点的名称从ubuntu-14更改为其他。我希望能够通过在 / etc / default / docker 文件中添加一行来设置标签,因为私有云我最终将在其中运行我的集群没有办法设置类似于其他云提供商(例如AWS)的实例标签。

I would like to know how to manually change the name of my nodes from "ubuntu-14" to something else. I would prefer to be able to set the tags by adding a line to the /etc/default/docker file, as the private cloud I will eventually be running my cluster within does not have a way to set instance tags similar to other cloud providers such as AWS.

tldr:我有3个流氓ubuntu框运行swarm 1名主人+ 2名工作人员)。默认情况下,工作人员的标签名称为ubuntu-14,我想通过在每个工作人员的 / etc / default / docker 文件中添加内容来手动更改。我添加了什么?

tldr: I have 3 vagrant ubuntu boxes running swarm (1 master + 2 workers). The workers by default have the tag name "ubuntu-14" and I want to manually change that by adding something to the /etc/default/docker file on each worker. What do I add?

推荐答案

解决方案



The solution

## change the hostname
hostname myname
## restart docker
sudo service docker restart

我刚刚通过编辑 / etc / hostname 文件更改了我的流氓框的主机名,将ubuntu-14更改为master,worker1或worker2。然后我重新启动了我的机器,也不得不重新启动每个机器上的docker服务,使用 sudo service docker restart 。我也摧毁了我的旧容器,再次跑了我不知道这一步是否必要,但是我做的很好。

I just changed the hostnames of my vagrant boxes by editing the /etc/hostname file and changing ubuntu-14 to master, worker1 or worker2. Then I restarted my machines and also had to restart the docker services on each machine with sudo service docker restart. I also destroyed my old containers and ran them again I'm not sure if this step is necessary, but I did it for good measure.

这篇关于Docker群:如何手动设置节点名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆