How to backup your docker container
--Create your new public repository on Docker Hub
-- write password in file
[root@mum00byn ~]# nano dockerpwd.txt
-- pass on the password in file to the docker login command. This avoids entering the password in cleartext and showing up in bash history.
[root@mum00byn ~]# cat dockerpwd.txt | docker login --username manojpawar --password-stdin
Login Succeeded
[root@mum00byn ~]# rm dockerpwd.txt
-- Commit changes to a running container to a new image
[root@mum00byn ~]# docker container commit <container-id> skillrepo-wordpress:1.0
-- Tag the newly created image
[root@mum00byn ~]# docker image tag skillrepo-wordpress:1.0 manojpawar/skillrepo-wordpress:1.0
-- Push the tagged image to your repository
[root@mum00byn ~]# docker image push manojpawar/skillrepo-wordpress:1.0
--Backup data from running containers to the local system
[root@mum00byn ~]# cd /opt/mgpawar/Skill_Repository_DataBackup/wp
[root@mum00byn wp]# docker cp wordpress_wordpress_1:/var/www/html/ .
[root@mum00byn ~]# cd /opt/mgpawar/Skill_Repository_DataBackup/db
[root@mum00byn db]# docker cp wordpress_db_1:/var/lib/mysql/ .
Also you can see all volumes for all docker containers at this path, which can be backed up - /var/lib/docker/volumes/
Comments
Post a Comment