So I was playing around with devicemapper docker storage driver the other day. It was quite nice but when I stopped the modified docker daemon and tried to start the docker service in “normal” way, I received the following error:
root@carbon:~# service docker start
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
Clearly something had gone wrong. Upon running:
systemctl status docker.service
I found the following line most helpful in fixing the error:
Jan 24 22:33:17 carbon dockerd: Error starting daemon: error initializing graphdriver: /var/lib/docker contains several valid graphdrivers: devicemapper, aufs; Please cleanup or explicitly choose storage driver (-s
So I ran the following command in order to remove my devicemapper driver:
rm -rf /var/lib/docker/devicemapper
Boom it worked!
Alternatively, I could’ve backed it up to tmp instead by running:
mv /var/lib/docker/devicemapper /tmp/
But I didn’t need any of my images anyway so I removed it.
Hope this helps.
Working with Docker on corporate proxy is a painful experience. Mainly because there aren’t many guides available to do it. Finally after banging my head on the desk for a long time, my friend and colleague at https://nextmetaphor.io showed me how to do it.
First of all, fire up your terminal and open up docker tty in screen.
If you see a blank screen, press enter. You should see a prompt.
Make sure you are in the docker VM by typing the hostname command. You should see the response as moby. If your response is other than that, try that screen command again.
Now we want to view docker’s routing table. This is because we’ll need to find out the IP address of the host machine that is running the proxy. This is specific to my setup where I have a charles proxy server running on my machine which proxies to the remote corporate proxy.
/ # netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.65.1 0.0.0.0 UG 0 0 0 eth0
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.65.0 0.0.0.0 255.255.255.240 U 0 0 0 eth0
Get the gateway entry for 0.0.0.0. In my case this is 192.168.65.1. That’s the IP for the host machine running docker. For the proxy running on your local machine, just map it to the port. My charles server is running on port 8099 so my proxy will be:
Close screen by pressing Ctrl + a \ key. Once you’ve exited, open up docker for mac preferences.
Go to the “advanced” tab and fill out your proxy settings.
Hit apply and restart when done!
Your Docker for Mac should now work harmoniously with your proxy!
Deploying applications is a complex task. You have to create some VMs, be it on DigitalOcean or AWS, download and install necessary prerequesites and then deploy your application. It would be easy if it were to end there, however, it doesn’t.
Following this you have application maintenance which includes deploying updated versions of your application in addition to other things like bug fixes. And this is where the real complexity starts. Your updated version might need another dependent application to be installed which in turn might need a version of some random tool to be upgraded. You did what was necessary but then you find out that the deployment of the updated application failed because you forgot to do that one null check in some corner of your application. So frantically you download the previous version of your application and try to restore it only to find that it doesn’t work anymore since you upgraded that random tool to support your newer application.
While all this is happening either your entire application is unavailable because your application is single instance or if it is indeed multi-instance split by a loadbalancer, all the other instances are being stressed out because one of the node is down.
And now you are thinking. Well, there has to be a better way.
Well my friend, there is.
Lets start off by deploying a single MySQL DB instance. For this, we’re going to use the default mysql image from docker hub. In order to deploy anything to CoreOS, you need to first create a service file. Here’s one for the MySQL that we’re going to deploy.
Description=MySQL database for wordpress
ExecStartPre=-/usr/bin/docker stop wpdb
ExecStartPre=-/usr/bin/docker rm wpdb
ExecStartPre=-/usr/bin/docker pull mysql:latest
ExecStart=/usr/bin/docker run -e MYSQL_ROOT_PASSWORD=glory86 --name wpdb -t mysql:latest
Save that file as
wpdb.service. Lets examine that file. As you can see, the file is split into three distinct sections.
X-Fleet. The Unit section tells CoreOS, or more specifically
fleet, what this service is about and what it is for. Since this one is quite simple, we only have a
Description here. Continue reading
So a lot of times when you’re working with some cool docker containers, you might need to remove all those dead containers that are just lying around. This could happen if you’re running docker containers in background or forgot to use
Not to worry, just run this command to remove ALL running docker containers in one go: Continue reading