Skip to content

Instantly share code, notes, and snippets.

@etoews
Created May 11, 2016 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etoews/dac9dcfc79ed8ec8746393073f4f7817 to your computer and use it in GitHub Desktop.
Save etoews/dac9dcfc79ed8ec8746393073f4f7817 to your computer and use it in GitHub Desktop.
Example of copy data to a new cluster from an from old cluster. https://getcarina.com/docs/tutorials/migrate-cluster/
$ eval $(carina env old)
$ export DOCKER_CERT_PATH_OLD=$DOCKER_CERT_PATH
$ export DOCKER_HOST_OLD=$DOCKER_HOST
$ export DOCKER_VERSION_OLD=$DOCKER_VERSION
$ eval $(carina env new)
$ docker create --name old-swarm-data --volume /etc/docker cirros
$ tar -c -C "$DOCKER_CERT_PATH_OLD" . | docker cp - old-swarm-data:/etc/docker/
$ docker create --name webvolume --volume /var/www/ --volume /etc/apache2 --volume /etc/ssl cirros
$ docker run --rm \
--env DOCKER_HOST=$DOCKER_HOST_OLD \
--env DOCKER_VERSION=$DOCKER_VERSION_OLD \
--env DOCKER_TLS_VERIFY=1 \
--env DOCKER_CERT_PATH=/etc/docker \
--volumes-from webvolume \
--volumes-from old-swarm-data \
--workdir /var \
docker:$DOCKER_VERSION_OLD \
/bin/sh -c "docker cp webvolume:/var/www/ - | tar -x"
$ docker run --rm -it --volumes-from webvolume cirros ls /var/www
1.txt
2.txt
html
$ docker run --rm -it --volumes-from webvolume cirros ls /var/www/html
index.html
# This is just for test data on the old cluster
$ eval $(carina env old)
$ docker create --name webvolume --volume /var/www/ --volume /etc/apache2 --volume /etc/ssl cirros
$ docker run --rm --volumes-from webvolume cirros /bin/sh -c "echo '1' > /var/www/1.txt"
$ docker run --rm --volumes-from webvolume cirros /bin/sh -c "echo '2' > /var/www/2.txt"
$ docker run --rm --volumes-from webvolume cirros /bin/sh -c "mkdir /var/www/html"
$ docker run --rm --volumes-from webvolume cirros /bin/sh -c "echo 'hello world' > /var/www/html/index.html"
$ docker run --rm --volumes-from webvolume cirros ls /var/www
1.txt
2.txt
html
$ docker run --rm --volumes-from webvolume cirros ls /var/www/html
index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment