Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start with persistent storage (/data/dump.rdb) volume-shared-filesystems #47

Closed
a1exus opened this issue Feb 18, 2016 · 5 comments
Closed

Comments

@a1exus
Copy link

a1exus commented Feb 18, 2016

I'm trying to "start with persistent storage" Redis docker using Docker run reference, however, inside of docker container I see /data/dump.rdb file, yet on host I do not:

alexus@mbp:~ $ docker run --name redis --volume=data:/data/:rw -p 6379:6379 -d redis
720d5faa3c90ae73bf0add2013fe074dd4bc14a6c30b6c593fa88646371efd4d
alexus@mbp:~ $ ls data/
alexus@mbp:~ $

please advise)

@yosifkit
Copy link
Contributor

The container-dest must always be an absolute path such as /src/docs. The host-src can either be an absolute path or a name value. If you supply an absolute path for the host-dir, Docker bind-mounts to the path you specify. If you supply a name, Docker creates a named volume by that name.
A name value must start with start with an alphanumeric character, followed by a-z0-9, _ (underscore), . (period) or - (hyphen). An absolute path starts with a / (forward slash).
--docs.docker.com

It looks like docker is treating that as a name for a volume rather than a path. docker inspect redis should let you figure out where the docker managed volume is actually at. If you just want it to store the data in the current directory, then this should work: docker run --name redis --volume="$PWD/data":/data/:rw -p 6379:6379 -d redis.

@a1exus
Copy link
Author

a1exus commented Feb 20, 2016

I tried your recommendations, however end up with same results, docker inspect redis shows correct paths to both mount points.

alexus@mbp:~ $ docker run --name redis --volume="$PWD/data":/data/:rw -p 6379:6379 -d redis
8b1ab3d4f3da7947a1b847972252711271889367d8be1f08f286bd60a62c1b3e
alexus@mbp:~ $ ls data/
alexus@mbp:~ $ docker exec -it $(docker ps --all --quiet --filter name=redis) redis-cli
127.0.0.1:6379> save
(error) ERR
127.0.0.1:6379> 
alexus@mbp:~ $ docker inspect redis | grep -A6 Mounts
    "Mounts": [
        {
            "Source": "/Users/alexus/data",
            "Destination": "/data",
            "Mode": "rw",
            "RW": true
        }
alexus@mbp:~ $ 

without --volume:

alexus@mbp:~ $ docker run --name redis -p 6379:6379 --detach redis
61cb8ed3e1ac6862ccdfac8d0e12526e16592b239f37934ee6a2e21bf12a3822
alexus@mbp:~ $ docker exec -it $(docker ps -a -q --filter name=redis) redis-cli
127.0.0.1:6379> save
OK
127.0.0.1:6379> 
alexus@mbp:~ $ docker exec -it $(docker ps -a -q --filter name=redis) bash
root@61cb8ed3e1ac:/data# ls                                                                                                                                                                                                                  
dump.rdb
root@61cb8ed3e1ac:/data# 

@yosifkit
Copy link
Contributor

We should implement a fix similar to docker-library/mongo#81 (and the other issues linked there), but you can work around it with the following:

docker run -d --name redis --user 1000:50 -v $PWD/data:/data --entrypoint redis-server redis

Once we make the similar fix you wouldn't need the --entrypoint flag.

@a1exus
Copy link
Author

a1exus commented Feb 23, 2016

seems fine now, I also added --appendonly yes for "persistent storage" - Do I still need to do that?)

$ docker run --detach --name redis --user 1000:50 --volume=$PWD/data:/data --entrypoint redis-server redis --appendonly yes
600cd340e803f765d1978b4f45410334aecb26e7005c2ade8ffc38bca6e57da9
$ docker exec -it $(docker ps --all --quiet --filter name=redis) redis-cli
127.0.0.1:6379> save
OK
127.0.0.1:6379> 
$ ls data/
appendonly.aof  dump.rdb
$ 

@yosifkit
Copy link
Contributor

Yeah, you will still need that, since that is not the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants