Docker – Debian – Kernel panick – Automatic restart

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You have a remote server (Debian) running some Docker containers and you want to make sure that they all restart in the event of a kernel panick.

solution

  • Add an automatic restart after a kernel panick by running:

  • Emulate a kernel panick by running the following (SysRq more info here :

  • Check that the containers have restarted again with docker ps (NOTE: the containers should have been enabled to autorestart)

Docker Debian locales installation

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You want to install some default locales in a Docker image, and the suggestion is to use locale-gen to do so, but it does not work as expected.

Solution

In order to be able to use the locale-gen and install the locales you need you will have to uncomment the ones needed from /etc/locale.gen first and then use the locale-gen. Example below:

Dockercloud-agent error: …Error creating default \”bridge\” network:…

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

When trying to use the dockercloud-agent with docker you have the following error in the /var/log/dockercloud/agent.log

Solution

If you remove the file var/lib/docker/network/files/local-kv.db as suggested here, then if you look again at the log files, it should be a message that the docker daemon has been started:

Clearing unused (dangling) docker volumes

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

After you start using and building Docker images, there is a case that there is a lot of space used even after deleting images and containers (a few GB maybe).

Solution

To clean out the volumes that are no longer used (ie dangling) use the following:

Removing Docker containers that have exited

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

You would like to clear Docker containers that have been exited and not cleared properly.

Solution

Run the following to find out the containers that have exited and remove them.

Error response from daemon: conflict: unable to delete xxx (must be forced) – image is referenced in one or more repositories

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

Trying to remove some unused docker images that you no longer use with docker rmi image_id you get the following error message:

Solution

Use the following to delete multiple images (ie ubuntu):

Mentioned here

Remove terminated/unused docker containers from your system

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Problem

After playing around with docker containers for some time the terminated/unused ones are still hanging around your system, and prevent you from using a new container with the same name as any of the previous ones with the error:

Solution

You can remove all the containers by using the following:

Creating a simple rails docker image for testing in cloud deployment

Email this to someoneShare on Google+Share on FacebookTweet about this on TwitterShare on LinkedIn

Trying to deploy a rails application in a cloud provider ie dreamhost, that uses OpenStack these are the steps needed:

  1. Install docker in your development machine and your cloud provider by following the installation instructions from here
  2. Create an account in Docker Hub, that will be needed later on to push your docker image with the application
  3. Pull the official rails docker image to your development environment:
  4. Create a new simple rails application:
  5. Change to the application directory and add a Dockerfile in the root directory containing the following:
  6. Build your new image by using:
  7. Check that your image was build by using:
  8. Start the container with:
  9. Make sure that you can see the initial rails page by using your browser to go to http://127.0.0.1:3000
  10. Push your image to your Docker Hub account by first logging in to it from the command line: , and then when you get ‘Login Succeeded’, push your image to your account:
  11. TBC