Skip to content

Instantly share code, notes, and snippets.

@arsham
Last active January 11, 2019 14:34
Show Gist options
  • Save arsham/a63f013fb284b261f4ece2245272a804 to your computer and use it in GitHub Desktop.
Save arsham/a63f013fb284b261f4ece2245272a804 to your computer and use it in GitHub Desktop.
Create a new vm and join the swarm (#docker)

About

We want to create a new vm and join the swarm.

Argument order

name, cpu count, memory, disk
create_machine() {
    local JOIN_COMMAND=$(docker swarm join-token manager | grep token | tr -s " ")
    docker-machine create -d virtualbox \
        --virtualbox-cpu-count $2 \
        --virtualbox-memory $3 \
        --virtualbox-disk-size $4 \
        $1
    docker-machine ssh $1 $JOIN_COMMAND
}

Example

create_machine vm1 4 4096 20000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment