Home  >  Article  >  Operation and Maintenance  >  How to debug source code in docker?

How to debug source code in docker?

coldplay.xixi
coldplay.xixiOriginal
2020-06-12 13:00:563178browse

How to debug source code in docker?

#How to debug source code in docker?

How to debug the source code in docker:

After studying the official compilation steps of docker, I found that local compilation is also very simple. You only need to do it in the docker source code. Just execute the following command in the directory:

./hack/make.sh binary

The above command will only generate the docker binary file, but it will definitely not be so smooth. You will find errors when you execute this command. If the error reported during the first execution should be that the corresponding go dependency package cannot be found. So let’s start solving the first problem now, go dependency packages.

The most direct way to solve the go dependency packages is to go to github or other places one by one to download them locally, but this is very troublesome. Docker depends on many go language packages, and the dependent packages may depend on other packages. Here is a simple and practical method, which is also the convenience of go language project management. Use the go get command to automatically download. For example, if you find that the error reported is a dependent package in a certain directory of docker, you can execute it as follows:

go get -v ./src/github.com/docker/docker/...

After this command is executed, the packages that the source files in the entire docker directory depend on will be Download automatically. If you find that source files in other directories also report the same error, you can solve it according to the following methods. However, it needs to be emphasized here that these downloads will download the latest packages. If you compile the old docker, there will definitely be problems. If you compile the latest docker code, there will definitely be no problems, because the official compilation is this way.

The commands executed above are all based on the successful establishment of the go language environment. The go I installed is version 1.3.3, which is installed in source code mode. Install it under /export/servers/go, and then place all go language project source code directories in /export/servers/gopath. Then configure the environment variables in the .bashrc file in the user's root directory as follows:

export GOPATH=/export/servers/gopath
export GOROOT=/export/servers/go
export GOARCH=amd64
export GOOS=linux


Recommended tutorial: "docker video tutorial

The above is the detailed content of How to debug source code in docker?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn