How to retrieve GOPATH from Docker container?

China☆狼群 提交于 2020-01-01 16:32:38

问题


My objective is to have a self contained Go Workspace per project.

Is it possible to retrieve a Go workspace and Go environment variables from a running Docker container to be used by an IDE or Text Editor for development?

I have already tried mapping a volume to the container with the go tools and dependencies. But that requires always setting the GOPATH to the current workspace, and requires to have the go tools and dependencies on the host.


回答1:


You can at least set and pass those environment variable when launching your container:

docker run -e "GOPATH=/a/mounted/path" -v [host-src:]container-dest --rm -it <yourImage>

By using -v, you allow your host to share a folder with your container.



来源:https://stackoverflow.com/questions/35687929/how-to-retrieve-gopath-from-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!