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

Problem

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

level=fatal msg="Error starting daemon: Error initializing network controller: Error creating default \"bridge\" network: cannot create network xxx... (docker0): conflicts with network yyy.... (docker0): networks have same bridge name" 

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:

016/11/17 10:30:28 Respawning docker daemon
2016/11/17 10:30:28 Starting docker daemon: [/usr/bin/docker daemon -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375 --userland-proxy=false --tlscert /etc/dockercloud/agent/cert.pem --tlskey /etc/dockercloud/agent/key.pem --tlscacert /etc/dockercloud/agent/ca.pem --tlsverify]
2016/11/17 10:30:28 Docker daemon (PID:4036) has been started

Clearing unused (dangling) docker volumes

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:

sudo docker volume ls -qf dangling=true | xargs -r sudo docker volume rm

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

Problem

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

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

Solution

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

docker images ubuntu | tail -n +2 | awk '{ print $1 ":" $2 }' | xargs sudo docker rmi

Mentioned here