Ubuntu Docker source code compilation (1.9.1) details

  • 2020-05-24 06:32:39
  • OfStack

Ubuntu Docker source code compilation:

There is a lot of information on the Ubuntu Docker source code compilation on the Internet, but for the specific operation, and the implementation of the command is not much detail, after I 1 time of suffering, finally get the source code compilation done, here recorded for future use reference,

1. System environment

Ubuntu14. 04 desktop 64

2. Install Docker (compile Docker within Docker)

$ sudo apt-get update

$ sudo apt-get install wget

$ wget -qO- https://get.docker.com/ | sh

3. Pull the Docker development environment container

# docker pull docker-dev:1.9.1

4. Download the Docker source code to your local machine


# apt-get install git 


# mkdir -p /home/docker/src 



# cd /home/docker/src 



# git clone https://github.com/docker/docker.git 



# cd docker 



# git checkout v1.9.1 

5. Compile

In fact, the Docker compiler container comes with the source code, and the fourth step here is to download the source code to the local machine, mainly for the convenience of twice development.

New code can be developed to replace the existing code in the container for custom development.

1. Create local compilation results to save the directory

# mkdir -p /home/docker/bundles

2. Start the container and map the local code to the container:


# docker run --rm -it --privileged \ 
  -e BUILDFLAGS \ 
  -e DOCKER_CLIENTONLY \ 
  -e DOCKER_EXECDRIVER \ 
  -e DOCKER_EXPERIMENTAL \ 
  -e DOCKER_GRAPHDRIVER \ 
  -e DOCKER_STORAGE_OPTS \ 
  -e DOCKER_USERLANDPROXY \ 
  -e TESTDIRS -e TESTFLAGS \ 
  -e TIMEOUT \ 
  -v /home/docker/bundles:/go/src/github.com/docker/docker/bundles \ 
  -v /home/docker/src:/tmp \ 
  docker-dev:1.9.1 \ 
  bash 

3. Compile in the container (this command is executed in the container) :

# cp -a /tmp/docker/* /go/src/github.com/docker/docker/

# hack/make.sh binary

4. After compiling, exit the container, check the local result path, and the compiled Docker executable file has been generated:

# ls -l /home/docker/bundles

6. Verify

# cd /home/docker/bundles/1.9.1/binary

# ./docker version

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: