Open isartcanyameres opened 8 years ago
Here after some test for COPY vs mount tl;dr: COPY takes 27s while mount 18
Details and commands used:
#with COPY
time docker build -f Dockerfile --no-cache -t client-vpn . 1>/dev/null
real 0m27.424s user 0m0.027s sys 0m0.015s docker rm -f $(docker ps -aq)
docker rm -f $(docker ps -aq)
time docker run --net=host --privileged -v /dev/net/:/dev/net/ \
--name client-vpn -d client-vpn
real 0m0.306s user 0m0.007s sys 0m0.006s
#with mount
cat Dockerfile | grep -v COPY > Dockerfile.noCOPY
time docker build -f Dockerfile.noCOPY --no-cache -t client-vpn . 1>/dev/null
real 0m18.205s user 0m0.018s sys 0m0.010s docker rm -f $(docker ps -aq)
docker rm -f $(docker ps -aq)
time docker run --net=host --privileged -v /dev/net/:/dev/net/ \
-v /home/CNSMO/ENVS/VPNClient-slave.1/client.conf:/etc/openvpn/client.conf:ro \
-v /home/CNSMO/ENVS/VPNClient-slave.1/client.crt:/etc/openvpn/client.crt:ro \
-v /home/CNSMO/ENVS/VPNClient-slave.1/ca.crt:/etc/openvpn/ca.crt:ro \
-v /home/CNSMO/ENVS/VPNClient-slave.1/client.key:/etc/openvpn/client.key:ro \
-v /home/CNSMO/ENVS/VPNClient-slave.1/tun_manager.sh:/etc/openvpn/tun_manager.sh:ro \
--name client-vpn -d client-vpn
real 0m0.341s user 0m0.022s sys 0m0.014s
Instead of copying files at the build, you can mount it at the run with
-v
option. (-v /home/CNSMO/ENVS/VPNClient-slave.1/client.conf:/etc/openvpn/client.conf:ro
) Multiple files can be mounted. If files are mounted, you could publish the container on a public repo and get it instead of compiling it. Doing this can speed up the deployment significantly (compiling the docker can be very slow). To check the time saved use command :time docker build --no-cache -t client-vpn .
An example of use can be found here: https://github.com/cyclone-project/federated-filtering-proxy-with-docker/blob/master/startFilteringProxy.sh#L54