patternbashMinor
Pulling Docker Machine IP
Viewed 0 times
dockerpullingmachine
Problem
I am working with MongoDB through Docker, and I have a terrible bash command to pull the Docker Machine IP so I can sanely connect locally.
How can I optimise the
export dockerip="$(docker-machine ls | awk '{print $5}' | sed -n '2p' | sed 's/tcp:\/\///' | sed 's/\:2376//')"
mongo --host "$dockerip" --port 27017How can I optimise the
docker-machine line?Solution
docker-machine provides a simple way to get the IP of the host machinemongo --host `docker-machine ip default` --port 27017I'm using
default here, since that's the name of the machine I'm using.Code Snippets
mongo --host `docker-machine ip default` --port 27017Context
StackExchange Code Review Q#104937, answer score: 5
Revisions (0)
No revisions yet.