Page tree
Skip to end of metadata
Go to start of metadata

We will talk about centralizing your app docker container and the data volume the container uses.

First, we will package the docker container's data volume into a tar file

docker run --rm --volumes-from data-container-backup --name tmp-backup -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /folderToBackup

then, we will create a new container and extract the tar inside it. Since it has the data volume inside it, we'll call it "Data Volume container"

docker run -d -v $(pwd):/backup --name data-backup ubuntu /bin/sh -c "cd / && tar xvf /backup/backup_data.tar"

Now we will create a new image from this "data volume container"

docker commit data-backup repo/data-backup:$VERSION

Push it to the cloud or AWS docker registry

docker push repo/data-backup:$VERSION

Go to the remote location/dev local host and grab the  data volume container image

docker run -v /folderToBackup --entrypoint "bin/sh" --name data-container repo/data-backup:${VERSION}
Run your container leveraging "volumes from" so it knows where to get the data (from data volume container)
Access the developers env and run this:

docker run -d -it -p8080:80/tcp -v $(pwd)/html:/var/www/html --volumes-from=damage-data-container

  • No labels
Write a comment…