Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up deployment by mounting files at run instead of copying them at build #10

Open
isartcanyameres opened this issue Jul 21, 2016 · 1 comment

Comments

@isartcanyameres
Copy link
Member

isartcanyameres commented Jul 21, 2016

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

@bryan-brancotte
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants