本文介绍了Docker数据卷容器。我似乎无法备份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读这些链接:



  1. 然后在:

    (在这种情况下不是 / var / db / root

    因此,在这种情况下, z Z 是合适的,但通常可能更喜欢 Z 为隔离。


    Reading these links:

    1. https://docs.docker.com/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes
    2. Backing up data volume containers off machine

    My understanding is I can take a data volume container and archive its backup.However reading the first link I can't seem to get it to work.

    docker create -v /sonatype-work --name sonatype-work sonatype/nexus /bin/true
    

    I launch sonatype/nexus image in a container using:

    --volumes-from sonatype-nexus
    

    All good, after running nexus, i inspect the data volume, i can see the innards created, and stop and remove nexus and start again, all changes saved.

    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
    f84abb054d2e        sonatype/nexus      "/bin/sh -c 'java   -"   22 seconds ago      Up 21 seconds       0.0.0.0:8081->8081/tcp   nexus
    1aea2674e482        sonatype/nexus      "/bin/true"              25 seconds ago      Created                                      sonatype-work
    

    I want to now back up sonatype-work, but with no luck.

    [root@ansible22 ~]# pwd
    /root
    [root@ansible22 ~]# docker run --volumes-from sonatype-work -v $(pwd):/backup ubuntu tar cvf /backup/sonatype-work-backup.tar /sonatype-work
    tar: /backup/sonatype-work-backup.tar: Cannot open: Permission denied
    tar: Error is not recoverable: exiting now
    

    I have tried running as -u root, I also tried with:

    /root/sonatype-work-backup.tar
    

    When doing so, i can see it taring stuff, but I don't see the tar file. Based on the example and my understanding I don't think thats right anyway.

    Can anyone see what I'm doing wrong?

    EDIT: Linux Version Info

    Fedora release 22 (Twenty Two)
    NAME=Fedora
    VERSION="22 (Twenty Two)"
    ID=fedora
    VERSION_ID=22
    PRETTY_NAME="Fedora 22 (Twenty Two)"
    ANSI_COLOR="0;34"
    CPE_NAME="cpe:/o:fedoraproject:fedora:22"
    HOME_URL="https://fedoraproject.org/"
    BUG_REPORT_URL="https://bugzilla.redhat.com/"
    REDHAT_BUGZILLA_PRODUCT="Fedora"
    REDHAT_BUGZILLA_PRODUCT_VERSION=22
    REDHAT_SUPPORT_PRODUCT="Fedora"
    REDHAT_SUPPORT_PRODUCT_VERSION=22
    PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
    VARIANT="Server Edition"
    VARIANT_ID=server
    Fedora release 22 (Twenty Two)
    Fedora release 22 (Twenty Two)
    
    解决方案

    The reason for this is related to selinux labelling. There are a couple of good Project Atomic pages on this:

    Docker and Linux

    Then in Using Volumes with Docker can Cause Problems with SELinux:

    (In this case not /var/db but /root)

    So either z or Z are suitable in this case but one might usually prefer Z for the isolation.

    这篇关于Docker数据卷容器。我似乎无法备份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 22:43