I am working with Docker on my windows machine via git bash. Since git bash does not record the current status on closing, I need to set some environment variables related to Docker every time when I start a new terminal. The command I would like to run before start-up is:
eval $(docker-machine env)
Or better yet, have a bash script including other logics. For example if docker machine is not up, start the machine first, etc. Is there a way to automatically run bash command or script before opening a new git bash window?
I would recommend creating a new file under your home folder( ~/
) namely ~/.bashrc
which is read by your terminal when it first starts-up. Add a function say myStartUpFunction()
that runs your command as you need.
myStartUpFunction() {
docker-machine env
}
myStartUpFunction
This would enable you to run the docker-machine env
every time a new terminal session is opened.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.