Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Upgrade Docker and restart running containers
#!/bin/bash
datenow=$(date +%s)
sudo docker ps > /tmp/docker."$datenow"
sudo apt-get update && sudo apt-get install -y lxc-docker
sudo docker start $(tail -n +2 /tmp/docker."$datenow" | cut -c1-12)
@cpswan

This comment has been minimized.

Copy link
Owner Author

@cpswan cpswan commented Jun 23, 2015

This doesn't deal gracefully with linked containers as it will not respect the dependency chain

@gmarkall

This comment has been minimized.

Copy link

@gmarkall gmarkall commented Jun 23, 2015

What is "$datenow"? Does it need setting outside the script?

@cpswan

This comment has been minimized.

Copy link
Owner Author

@cpswan cpswan commented Jun 23, 2015

@jpetazzo asked me why I didn't use docker ps -q for this (which just lists the container IDs and would avoid the need for cut). The answer is that I like to have the full ps information in a file so I can see what was running if there are errors bringing stuff back up.

@cpswan

This comment has been minimized.

Copy link
Owner Author

@cpswan cpswan commented Jun 23, 2015

good catch @gmarkall - copy/paste error from actual script to gist :(

@sahilsk

This comment has been minimized.

Copy link

@sahilsk sahilsk commented Jul 2, 2015

cool..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.