Skip to content

Instantly share code, notes, and snippets.

@safizn
Last active February 13, 2019 12:41
Show Gist options
  • Save safizn/95ec2fb4191f3b4ec6e67cacf9d5e58e to your computer and use it in GitHub Desktop.
Save safizn/95ec2fb4191f3b4ec6e67cacf9d5e58e to your computer and use it in GitHub Desktop.
docker-machine ls
docker-machine rm -f <specificNodeName>
docker-machine ssh <VMName>
# send commands to the docker daemon of the following vm:
eval $(docker-machine env <VMName>)
# in case some problems appear regarding certificates
docker-machine regenerate-certs <machineName>
# Open ports of docker-machine
# http://stackoverflow.com/questions/36286305/how-do-i-forward-a-docker-machine-port-to-my-host-port-on-osx
docker-machine stop <VMname>
VBoxManage modifyvm "<vmname>" --natpf1 ",tcp,,80,,80"
docker-machine start <VMName>
eval $(docker-machine env <vmname>)
# List open ports:
VBoxManage showvminfo "machine"
docker-machine ssh [machine-name] and tail -f /var/log/docker.log
____
NOTES:
#In case of docker-machine mounts :
• ./:/localVMPath - this will translate to the full host path C:/Users/Name/Projects:/localVMPath which is also available in the docker-machine VM (all of c:/)
• Where are regular path is only open between localVM and container. not the host.
WINDOWS users notes:
• Use Git bash
• Mount - enter only one of the machines and execute commands there, in order for mount to work on them.
# default values = cpu=1 memory=1024
docker-machine stop machine
VBoxManage modifyvm machine --cpus 2
VBoxManage modifyvm machine --memory 4096
docker-machine start machine
# Or limit it to --virtualbox-memory 512
docker-machine create -d virtualbox --virtualbox-memory <machine>
# Example
docker-machine create -d virtualbox --virtualbox-memory 16384 machine
docker-machine create -d virtualbox --virtualbox-memory=4096 --virtualbox-cpu-count=2 --virtualbox-disk-size=50000 <nameofVM>
# USAGE: define VM variable for VM name or use default & run.
if [[ -v VM ]]; then echo $VM; else VM=machine; fi
forwardPort() {
port=$1
echo "Forwarding port \"${port}\" in VM - \"${VM}\"."
VBoxManage modifyvm "$VM" --natpf1 ",tcp,,${port},,${port}"
}
docker-machine create -d virtualbox $VM
docker-machine stop $VM
forwardPort 443
# Node NIM - inspector manager - allows for chrome debuding of node.
forwardPort 9229
for i in {80..90}
do
forwardPort $i
done
for i in {8080..8090}
do
forwardPort $i
done
# BrowserSync ports
forwardPort 9901
forwardPort 9902
forwardPort 9903
docker-machine start $VM
VBoxManage showvminfo "${VM}"
eval $(docker-machine env $VM)
docker-machine ssh machine "echo 'export VAR=$PWD' >> ~/.profile"
# USAGE: set variable VM to virtual machine name. if not default will be used.
if [[ -v VM ]]; then echo $VM; else VM=machine; fi
docker-machine start $VM
eval $(docker-machine env $VM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment