Skip to content

Instantly share code, notes, and snippets.

@leite
Created March 23, 2016 21:05
Show Gist options
  • Save leite/0775cf421798a2e06c14 to your computer and use it in GitHub Desktop.
Save leite/0775cf421798a2e06c14 to your computer and use it in GitHub Desktop.
docker and devicemapper

docker and devicemapper

devicemapper is garbage, switch to aufs.

backup images

list images ...

$ docker ps -a

for each container you care for, stop and then commit it (could take a while ~10 minutes).

$ docker commit e198aac7112d export/server1 
$ docker commit a312312fddde export/server2
$ docker commit a312312fddde export/server3

and then export (could take a while too)

$ docker save export/server1 > export_server1.tar.gz
$ docker save export/server2 > export_server2.tar.gz
$ docker save export/server3 > export_server3.tar.gz

cleanup

$ docker rm $(docker ps -a -q)
$ docker rmi $(docker images -a -q)

aufs

supports?

check your current kernel and install the extra package:

$ sudo apt-get install linux-image-extra-$(uname -r)

edit /etc/init/docker.conf and aufs ...

DOCKER_OPTS="--storage-driver=aufs"

restart docker service, should be fine now (reboot machine - may be required).

$ service docker restart
$ docker info
Containers: 0
Images: 0
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Dirs: 1
Execution Driver: native-0.2
Kernel Version: 3.13.0-83-generic
WARNING: No swap limit support

restore images

$ docker load < export_server1.tar.gz
$ docker load < export_server2.tar.gz
$ docker load < export_server3.tar.gz

restore containers

create a compose file referencing new images.

database:
  container_name: database
  image: export/server2
  volumes:
    - /var/lib/mysql
    - ../shared/conf/mysql:/etc/mysql/conf.d
  environment:
    MYSQL_ALLOW_EMPTY_PASSWORD: 'no'
    MYSQL_USER: 'xxxxxxx'
    MYSQL_PASSWORD: '909090909'
    MYSQL_DATABASE: 'xxxxxxxxxx'

solr:
  container_name: solr
  image: export/server3
  stdin_open: true
  tty: true
  volumes:
    - ./lib/Apache/Solr/conf:/opt/solr/server/solr/instance1/conf

webserver:
  container_name: webserver
  image: export/server1
  stdin_open: true
  tty: true
  environment:
    ENV: 'xxxxxxxxx'
  volumes:
    - .:/usr/share/nginx/service
    - ../shared/conf/certs:/usr/share/nginx/certs
    - ../shared/conf/nginx:/etc/nginx/sites-enabled
    - ../shared/var/log:/var/log/nginx
  links:
    - database
    - solr

load with compose ad should be good now.

$ docker-compose -f restore.yml up -d

volume

volumes are left intact, you can reuse them if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment