Monday, November 3, 2014

Docker pitfalls like line endings on windows, dos2unix, permissions e.t.c



Having spent 2-3 weeks on making docker work ( which seemed pretty simple at first but then turned out to be like a peeling onion kind of a problem) ...felt like documenting all the blockers i faced:-

1. yes in my hurry to install docker without reading the official installations noted ..i managed to install the wrong docker ( what are the chances) .. so make sure you follow the right installation steps (https://docs.docker.com/installation/ubuntulinux/) and note they are different for <=ubuntun12.04


2. running docker e.t.c steps were simple to grasp .. but the interesting stuff came in when i discovered Dockerfile...i assumed it should look like the install script i have (that is called from the vagrantfile i have ..since currently i was using vagrant for my app) .....That was a big mistake. It took me sometime to learn the concept of "loosing context" and "new image being formed after every RUN in dockefile" ...so make sure you understand that after every RUN command .. the next command does not know anything about your state

3. in windows you will run into this issue  http://www.rsync.net/resources/howto/windows_rsync.html.. Use rsync .
and when you user rsync you might run into this issue
https://github.com/mitchellh/vagrant/issues/3230  ....which you can fix by modifying a file in vagrant (yucks!)
 just edit C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.5.1\plugins\synced_folders\rsync\helper.rb and add hostpath = "/cygdrive" + hostpath to line 74. It's a terrible solution but quick and simple.

4. If you manage to start the docker container on windows the next thing you will notice is .. none of your scripts are running. The reason is line endings on windows!!! dos2unix can help and rescue here   .. just go int the container and do dos2unix *.sh and it shall fix it. For some reason i tried to do the samething in my dockefile but it hung up ..everytime i build the container ( and this is when i gave up on my quest to make it run on windows)

5.  if you are running any scripts from dockerfile .. make sure your have permissions set correctly before you run docker or set  it within the dockerfile

6) Other great lesson i learned was ( thanks to my co-worker) ..to start with baseimages (http://phusion.github.io/baseimage-docker/) ...for a simpler and reliable(preloaded) start.

7) one more easily overlooked fact .. is you have to apt-get update before installing anything  on fresh  base image



8) ..i feel at this point that  ran into more things/notes/blockers during last 2-3 weeks .. but can not recall them right now .. will add them later if i can recall them .. but the feeling i got my the end of it was .. docker is not very intuitive ...it harder to debug and understand .. than it is to learn docker.

1 comment:

  1. I read your Blog Your information is really awesome, Thanks for sharing information about Devops Online Training Hyderabad

    ReplyDelete