Docker doesn't save data in host mounted volume

Urr4

I'm trying to start jenkins in a docker container using Docker Toolbox on Windows 7.

I run

docker run --name jenkins -p 8080:8080 -p 50000:50000 -v "//C/Users/myname/.jenkins:/var/jenkins_home" jenkins  

The jenkins starts up nicely, however there is nothing created under C:/Users/myname/.jenkins. I've created the folder but it stays empty.

When I now stop and remove the container and start it again, jenkins has lost everything I've done before.

What am I doing wrong?

TinkerTank

With Docker Toolbox, docker images don't actually run 'on' your windows machine, but rather on a virtual machine that's created on your windows machine.

It seems that host mounted volumes do have some caveats with Docker Toolbox on windows. See for example:

Perhaps there are some hints here that can help you to get it to work.


If you do want the data to persist between containers, even after deleting the jenkins container, you can use a data-volume for the jenkins homedir. In that case you would start jenkins as following:

docker run --name jenkins -p 8080:8080 -p 50000:50000 -v "/var/jenkins_home" jenkins

This basically creates a separate docker container for the /var/jenkins_home directory, allowing you to delete / upgrade / etc the jenkins container without affecting your data.

Do make sure that you understand what's going on here though. Read: https://docs.docker.com/engine/tutorials/dockervolumes/

this is also mentioned in the jenkins docker-image documentation: https://hub.docker.com/_/jenkins/


Alternatively: Could it be acceptable to just 'stop' and 'restart' the container whenever you need it? - In that case, you don't need the host mounted directories. In that case, just omit the -v options. This does make it hard to back-up your data, or to use a newer jenkins image.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Running docker on Ubuntu: mounted host volume is not writable from container

Docker: Permissions for a mounted volume

Docker doesn't create files in specified volume

How to give non-root user in Docker container access to a volume mounted on the host

docker data volume vs mounted host directory

Orphaned Docker mounted host volumes?

Docker MySQL Host Volume

Docker permissions development environment using a host mounted volume

Docker volume mount doesn't exist

docker couchdb data volume doesn't save to local filesystem

Docker volume: persist data on a remote host

Docker inside docker : volume is mounted, but empty

Docker options to remove host mounted named volume

Docker volume and host permissions

Docker, is it possible copy host's data to docker volume?

Can user privilege of docker container impact permission of host machine on mounted volume in docker-compose.yml?

Replace a file from host to container with mounted volume

Docker compose doesn't save data in volume

Docker mounted volume javascript not syncing

Pulseaudio resets volume control to 100% -- doesn't save volume

Docker: copy data from host to mounted host directory to access it from the running container

Docker on Windows Data Persistence - Host Mapping vs Data Volume

How to save user uploaded files to mounted volume using PHP, docker-compose?

ECS doesn't have enough free data blocks for docker image. How to provision enough volume/storage?

docker image - mounted volume is empty

Mounted host volume is not writable from host in Azure Pipelines

How to remove mounted Docker volume directory on host without root permissions

Docker Postgres data host volume mapping

Understanding host mounted volume changes in Docker