Created by: wangkuiyi
I noticed that we need this so we can re-use Docker images for development easily. In particular, suppose that I cloned Paddle into ~/work/paddle
on my MacBook Pro, and is going to change/develop Paddle's C++ source code, I would
-
Build a Docker image
paddle:dev
:cd ~/work/paddle docker build -t paddle:dev -f paddle/scripts/docker/Dockerfile .
This copies
~/work/paddle
into the image as/paddle
. -
Run the Docker image in a container with
~/work/paddle
on the host mounted into/paddle
:docker run -d -p 2022:22 -v /Users/yi/work/paddle:/paddle paddle:dev
This mounts
~/work/paddle
(aka/Users/yi/work/paddle
) to/paddle
in the container. This actually overlays the directory over the previously copied version. -
Edit files in
~/work/paddle/
on the host, and build the edited source files from within the container:ssh root@localhost -p 2022 $ cd /paddle $ WITH_GPU=OFF WITH_DOC=OFF WITH_STYLE_CHECK=ON WITH_SWIG_PY=ON paddle/scripts/docker/build.sh $ make -j4
The
cmake
command creates/paddle/build
directory in the container and makesmake
saves intermediate files in there. This/paddle/build
is actually created on the host as~/work/paddle/build
, and intermediate files will be saved on the host and will be re-used the next time we change code and re-build.