Docker: create a persistent volume in a specific directory
I need to create a persistent volume for Docker. The volume must be named extra-addons
and located in /mnt/
.
I run this command:
sudo docker volume create /mnt/extra-addons
I got this error message:
Error response from daemon: create /mnt/extra-addons: "/mnt/extra-addons" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path
Note that when I simply run: sudo docker volume create extra-addons
, I do not face this problem but when I inspect the volume in question using sudo docker inspect extra-addons
, I see it is located in a place I do not want:
[
{
"CreatedAt": "2018-04-21T14:40:25+03:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/extra-addons/_data",
"Name": "extra-addons",
"Options": {},
"Scope": "local"
}
]
I mean I rather want to see the volume like this: /mnt/extra-addons
Any idea?
docker
add a comment |
I need to create a persistent volume for Docker. The volume must be named extra-addons
and located in /mnt/
.
I run this command:
sudo docker volume create /mnt/extra-addons
I got this error message:
Error response from daemon: create /mnt/extra-addons: "/mnt/extra-addons" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path
Note that when I simply run: sudo docker volume create extra-addons
, I do not face this problem but when I inspect the volume in question using sudo docker inspect extra-addons
, I see it is located in a place I do not want:
[
{
"CreatedAt": "2018-04-21T14:40:25+03:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/extra-addons/_data",
"Name": "extra-addons",
"Options": {},
"Scope": "local"
}
]
I mean I rather want to see the volume like this: /mnt/extra-addons
Any idea?
docker
add a comment |
I need to create a persistent volume for Docker. The volume must be named extra-addons
and located in /mnt/
.
I run this command:
sudo docker volume create /mnt/extra-addons
I got this error message:
Error response from daemon: create /mnt/extra-addons: "/mnt/extra-addons" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path
Note that when I simply run: sudo docker volume create extra-addons
, I do not face this problem but when I inspect the volume in question using sudo docker inspect extra-addons
, I see it is located in a place I do not want:
[
{
"CreatedAt": "2018-04-21T14:40:25+03:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/extra-addons/_data",
"Name": "extra-addons",
"Options": {},
"Scope": "local"
}
]
I mean I rather want to see the volume like this: /mnt/extra-addons
Any idea?
docker
I need to create a persistent volume for Docker. The volume must be named extra-addons
and located in /mnt/
.
I run this command:
sudo docker volume create /mnt/extra-addons
I got this error message:
Error response from daemon: create /mnt/extra-addons: "/mnt/extra-addons" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path
Note that when I simply run: sudo docker volume create extra-addons
, I do not face this problem but when I inspect the volume in question using sudo docker inspect extra-addons
, I see it is located in a place I do not want:
[
{
"CreatedAt": "2018-04-21T14:40:25+03:00",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/extra-addons/_data",
"Name": "extra-addons",
"Options": {},
"Scope": "local"
}
]
I mean I rather want to see the volume like this: /mnt/extra-addons
Any idea?
docker
docker
edited Apr 22 '18 at 14:52
Billal Begueradj
asked Apr 21 '18 at 11:32
Billal BegueradjBillal Begueradj
2271411
2271411
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
I found the solution:
I had to install local-persist plugin.
I had to mount the volume to create to the mount point as follows:
sudo docker volume create -d local-persist -o mountpoint=/mnt/ --name=extra-addons
Check if I got what I expected:
sudo docker volume inspect extra-addons
Result:
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local-persist",
"Labels": {},
"Mountpoint": "/mnt/",
"Name": "extra-addons",
"Options": {
"mountpoint": "/mnt/"
},
"Scope": "local"
}
]
That was what I am looking for.
add a comment |
If you don't want to install any plugins to your docker, I would recommend to create a symbolic link for your volume:
$ docker volume create <myVolume>
$ docker volume inspect <myVolume>
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/<myVolume>/_data",
"Name": "<myVolume>",
"Options": {},
"Scope": "local"
}
]
$ mkdir /mnt/<myVolume>
# if you already have data in your volume, you should copy it to `/mnt/<myVolume>` now
$ sudo rm -rf /var/lib/docker/volumes/<myVolume>/_data
$ sudo ln -s /mnt/<myVolume> /var/lib/docker/volumes/<myVolume>/_data
Now feel free to use your volume as usual (with all your data beeing in /mnt
as you wanted)
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f439106%2fdocker-create-a-persistent-volume-in-a-specific-directory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found the solution:
I had to install local-persist plugin.
I had to mount the volume to create to the mount point as follows:
sudo docker volume create -d local-persist -o mountpoint=/mnt/ --name=extra-addons
Check if I got what I expected:
sudo docker volume inspect extra-addons
Result:
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local-persist",
"Labels": {},
"Mountpoint": "/mnt/",
"Name": "extra-addons",
"Options": {
"mountpoint": "/mnt/"
},
"Scope": "local"
}
]
That was what I am looking for.
add a comment |
I found the solution:
I had to install local-persist plugin.
I had to mount the volume to create to the mount point as follows:
sudo docker volume create -d local-persist -o mountpoint=/mnt/ --name=extra-addons
Check if I got what I expected:
sudo docker volume inspect extra-addons
Result:
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local-persist",
"Labels": {},
"Mountpoint": "/mnt/",
"Name": "extra-addons",
"Options": {
"mountpoint": "/mnt/"
},
"Scope": "local"
}
]
That was what I am looking for.
add a comment |
I found the solution:
I had to install local-persist plugin.
I had to mount the volume to create to the mount point as follows:
sudo docker volume create -d local-persist -o mountpoint=/mnt/ --name=extra-addons
Check if I got what I expected:
sudo docker volume inspect extra-addons
Result:
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local-persist",
"Labels": {},
"Mountpoint": "/mnt/",
"Name": "extra-addons",
"Options": {
"mountpoint": "/mnt/"
},
"Scope": "local"
}
]
That was what I am looking for.
I found the solution:
I had to install local-persist plugin.
I had to mount the volume to create to the mount point as follows:
sudo docker volume create -d local-persist -o mountpoint=/mnt/ --name=extra-addons
Check if I got what I expected:
sudo docker volume inspect extra-addons
Result:
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local-persist",
"Labels": {},
"Mountpoint": "/mnt/",
"Name": "extra-addons",
"Options": {
"mountpoint": "/mnt/"
},
"Scope": "local"
}
]
That was what I am looking for.
answered Apr 21 '18 at 13:05
Billal BegueradjBillal Begueradj
2271411
2271411
add a comment |
add a comment |
If you don't want to install any plugins to your docker, I would recommend to create a symbolic link for your volume:
$ docker volume create <myVolume>
$ docker volume inspect <myVolume>
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/<myVolume>/_data",
"Name": "<myVolume>",
"Options": {},
"Scope": "local"
}
]
$ mkdir /mnt/<myVolume>
# if you already have data in your volume, you should copy it to `/mnt/<myVolume>` now
$ sudo rm -rf /var/lib/docker/volumes/<myVolume>/_data
$ sudo ln -s /mnt/<myVolume> /var/lib/docker/volumes/<myVolume>/_data
Now feel free to use your volume as usual (with all your data beeing in /mnt
as you wanted)
add a comment |
If you don't want to install any plugins to your docker, I would recommend to create a symbolic link for your volume:
$ docker volume create <myVolume>
$ docker volume inspect <myVolume>
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/<myVolume>/_data",
"Name": "<myVolume>",
"Options": {},
"Scope": "local"
}
]
$ mkdir /mnt/<myVolume>
# if you already have data in your volume, you should copy it to `/mnt/<myVolume>` now
$ sudo rm -rf /var/lib/docker/volumes/<myVolume>/_data
$ sudo ln -s /mnt/<myVolume> /var/lib/docker/volumes/<myVolume>/_data
Now feel free to use your volume as usual (with all your data beeing in /mnt
as you wanted)
add a comment |
If you don't want to install any plugins to your docker, I would recommend to create a symbolic link for your volume:
$ docker volume create <myVolume>
$ docker volume inspect <myVolume>
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/<myVolume>/_data",
"Name": "<myVolume>",
"Options": {},
"Scope": "local"
}
]
$ mkdir /mnt/<myVolume>
# if you already have data in your volume, you should copy it to `/mnt/<myVolume>` now
$ sudo rm -rf /var/lib/docker/volumes/<myVolume>/_data
$ sudo ln -s /mnt/<myVolume> /var/lib/docker/volumes/<myVolume>/_data
Now feel free to use your volume as usual (with all your data beeing in /mnt
as you wanted)
If you don't want to install any plugins to your docker, I would recommend to create a symbolic link for your volume:
$ docker volume create <myVolume>
$ docker volume inspect <myVolume>
[
{
"CreatedAt": "0001-01-01T00:00:00Z",
"Driver": "local",
"Labels": {},
"Mountpoint": "/var/lib/docker/volumes/<myVolume>/_data",
"Name": "<myVolume>",
"Options": {},
"Scope": "local"
}
]
$ mkdir /mnt/<myVolume>
# if you already have data in your volume, you should copy it to `/mnt/<myVolume>` now
$ sudo rm -rf /var/lib/docker/volumes/<myVolume>/_data
$ sudo ln -s /mnt/<myVolume> /var/lib/docker/volumes/<myVolume>/_data
Now feel free to use your volume as usual (with all your data beeing in /mnt
as you wanted)
answered 1 min ago
Tom MekkenTom Mekken
168118
168118
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f439106%2fdocker-create-a-persistent-volume-in-a-specific-directory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown