docker-machine常用命令

1 在vbox中创建3个docker的结点(boot2docker)

docker-machine create -d virtualbox node-1

2 删除vbox中创建的docker结点

docker-machine rm -f node-1

3 停止/启动node

docker-machine start node-1
docker-machine stop node-1

4 用本地docker直接操作某个结点

eval $(docker-machine env node-1)
docker swarm ....

5 获取ip

docker-machine ip node-1

6 创建virtualbox类型主机后,如何使用固定ip

echo "ifconfig eth1 192.168.99.150 netmask 255.255.255.0 broadcast 192.168.99.255 up" | docker-machine ssh $NODE_NAME sudo tee /var/lib/boot2docker/bootsync.sh > /dev/null
docker-machine regenerate-certs $NODE_NAME

7 通过已有ip和key创建

    docker-machine create -d generic \
    --generic-ip-address $ip \
    --generic-ssh-user $username \
    --generic-ssh-key keys/id_rsa \
    $node

8 上述已有创建时,如果提示 tty present and no askpass program specified

需要在host机器上执行

sudoedit /etc/sudoer
# 最底下添加
USERNAME ALL=(ALL) NOPASSWD:ALL

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *