Giter Club home page Giter Club logo

Comments (8)

ndeloof avatar ndeloof commented on July 20, 2024

please open a PR

from docker.

benzht avatar benzht commented on July 20, 2024

I think the documentation is right. If you 'run' a new jenkins container without anything specified regarding the volume /var/jenkins_home, all data written there will be lost when you remove the container.
You basically have two options to make this data persistent across re-creating the jenkins container:

  1. mount a directory from the host, or
  2. link the volumes to a Data Volume Container

Off course, a not-bound volume actually exists on the disk in a docker-controlled volume. But it lives and dies with the container. When you pull a new version of the image and re-create the container, you loose the data.

Furthermore, the Docker documentation seems to suggest not to access files in containers through the host file system, but to use Docker-supplied commands.

from docker.

amouat avatar amouat commented on July 20, 2024

Actually, volumes don't die with the container unless you do docker rm -v. But good luck finding the folder that has your data! It's just subtleties like this that can mislead people.

Sorry for not coming up with a pull-request. I'm flat out at the minute, so it won't be this week either.

from docker.

benzht avatar benzht commented on July 20, 2024

You would have to do the docker rm as soon as you want to upgrade to a new version, wouldn't you?

from docker.

amouat avatar amouat commented on July 20, 2024

You could - and I'm certainly not advocating this approach - use docker inspect to find out where docker is keeping your volume, use docker rm without the -v to remove the container, then launch a new container with the volume bind mounted docker run -v /var/lib/docker/....:/var/jenkins_home ....

from docker.

benzht avatar benzht commented on July 20, 2024

We might be misunderstanding each other so I'm trying to rephrase it a bit.

  • Your original post seems to suggest accessing the files in the container using the hosts files system. At my current level of understanding Docker I would suggest not to do it.
  • If you want the data in your volumes to persist, I would (and actually do) use a host-mounted volume, or a Data Volume container. Neither option requires docker inspect to find out where the data lives on the disk

from docker.

amouat avatar amouat commented on July 20, 2024

I'm not suggesting accessing the files from the host, as much as just saying it's possible. (Although you are accessing the files from the host whatever you do, it's just you normally go via the container).

I think the wording "make that a persistent volume" is misleading, as there's not really such a thing as a transient volume. This misunderstanding is reinforced by the docker cp advice, which implies a running container is necessary to access the data and it disappears with the container. This very much isn't the case.

I would just reword a bit and replace the docker cp advice with something like docker run --volumes-from myjenkins -v $(pwd):/backup debian tar cvf /backup/backup.tar /var/jenkins_home

(Note that's untested and off the top of my head, but based on the example in the docker docs).

UPDATE: I suppose docker run --rm jenkins creates a transient volume. But that's not what we're discussing.

from docker.

benzht avatar benzht commented on July 20, 2024

OK. I stand corrected.
Removing the jenkins container docker rm jenkins (without -v) will keep the container intact on your disk....but there seems to be no easy way to discover it. My guess would be that for most users this is equivalent to being lost (me included, until now - I have 'lost' some data this way before).

from docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.