Change data directory of Docker
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
How can I change the data directory of Docker where docker save the container (or where lxc save the container)?
I have in my server a ssd and a hard drive ant I want that the container will be save on the hard drive.
Thanks
server lxc docker
add a comment |
How can I change the data directory of Docker where docker save the container (or where lxc save the container)?
I have in my server a ssd and a hard drive ant I want that the container will be save on the hard drive.
Thanks
server lxc docker
add a comment |
How can I change the data directory of Docker where docker save the container (or where lxc save the container)?
I have in my server a ssd and a hard drive ant I want that the container will be save on the hard drive.
Thanks
server lxc docker
How can I change the data directory of Docker where docker save the container (or where lxc save the container)?
I have in my server a ssd and a hard drive ant I want that the container will be save on the hard drive.
Thanks
server lxc docker
server lxc docker
asked Jun 2 '15 at 18:21
ssd_riderssd_rider
1401214
1401214
add a comment |
add a comment |
5 Answers
5
active
oldest
votes
I believe that in this guide you'll have a good explanation.
You can change Docker's storage base directory (where container and images go) using the -g option when starting the Docker daemon.
Ubuntu/Debian: edit your
/etc/default/docker
file with the-g
option:DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt"
Fedora/Centos: edit
/etc/sysconfig/docker
, and add the-g
option in the other_args variable: ex.other_args="-g /var/lib/testdir"
. If there's more than one option, make sure you enclose them in " ". After a restart, (service docker restart) Docker should use the new directory.
Using a symlink is another method to change image storage.
Caution - These steps depend on your current /var/lib/docker being an actual directory (not a symlink to another location).
1) Stop docker:
service docker stop
. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls
/var/lib/docker/
2b) Make a backup -
tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the
/var/lib/docker
directory to your new partition:mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink:
ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv:
ls /var/lib/docker/
(note the trailing slash to
6) Start docker back up
service docker start
7) restart your containersresolve the symlink)
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
add a comment |
In more recent Docker versions on Ubuntu you will edit /etc/default/daemon.json like so:
{
"data-root": "/new/location"
}
add a comment |
To change the data
directory in docker
it needs to be run with the option -g /my/data
. In my /etc/default/docker
I set:
DOCKER_OPTS="-g /srv/docker"
See also my notes here.
To change the data
directory in lxc
I put in /etc/lxc/lxc.conf
:
lxc.lxcpath = /srv/lxc
add a comment |
Upgrade to Docker 1.13.0.
From the Release Notes:
- New
The storage location of the Linux volume can now be moved
add a comment |
To expand on @MattK's answer:
The Docker documentation on controlling the Docker daemon suggests that platform independent way to do this is:
edit the /etc/docker/daemon.json file to contain the line
{
"data-root": "/mnt/docker-data",
(...)
}
where /mnt/docker-data
is the directory where you want the docker images and containers to live.
Then
sudo systemctl restart docker
You can check whether it worked by running
docker info
and look for the contents of the line that start with Docker Root Dir:
.
See also https://stackoverflow.com/a/50217666/2209313 and https://unix.stackexchange.com/q/452368/36043.
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f631450%2fchange-data-directory-of-docker%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
I believe that in this guide you'll have a good explanation.
You can change Docker's storage base directory (where container and images go) using the -g option when starting the Docker daemon.
Ubuntu/Debian: edit your
/etc/default/docker
file with the-g
option:DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt"
Fedora/Centos: edit
/etc/sysconfig/docker
, and add the-g
option in the other_args variable: ex.other_args="-g /var/lib/testdir"
. If there's more than one option, make sure you enclose them in " ". After a restart, (service docker restart) Docker should use the new directory.
Using a symlink is another method to change image storage.
Caution - These steps depend on your current /var/lib/docker being an actual directory (not a symlink to another location).
1) Stop docker:
service docker stop
. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls
/var/lib/docker/
2b) Make a backup -
tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the
/var/lib/docker
directory to your new partition:mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink:
ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv:
ls /var/lib/docker/
(note the trailing slash to
6) Start docker back up
service docker start
7) restart your containersresolve the symlink)
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
add a comment |
I believe that in this guide you'll have a good explanation.
You can change Docker's storage base directory (where container and images go) using the -g option when starting the Docker daemon.
Ubuntu/Debian: edit your
/etc/default/docker
file with the-g
option:DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt"
Fedora/Centos: edit
/etc/sysconfig/docker
, and add the-g
option in the other_args variable: ex.other_args="-g /var/lib/testdir"
. If there's more than one option, make sure you enclose them in " ". After a restart, (service docker restart) Docker should use the new directory.
Using a symlink is another method to change image storage.
Caution - These steps depend on your current /var/lib/docker being an actual directory (not a symlink to another location).
1) Stop docker:
service docker stop
. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls
/var/lib/docker/
2b) Make a backup -
tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the
/var/lib/docker
directory to your new partition:mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink:
ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv:
ls /var/lib/docker/
(note the trailing slash to
6) Start docker back up
service docker start
7) restart your containersresolve the symlink)
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
add a comment |
I believe that in this guide you'll have a good explanation.
You can change Docker's storage base directory (where container and images go) using the -g option when starting the Docker daemon.
Ubuntu/Debian: edit your
/etc/default/docker
file with the-g
option:DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt"
Fedora/Centos: edit
/etc/sysconfig/docker
, and add the-g
option in the other_args variable: ex.other_args="-g /var/lib/testdir"
. If there's more than one option, make sure you enclose them in " ". After a restart, (service docker restart) Docker should use the new directory.
Using a symlink is another method to change image storage.
Caution - These steps depend on your current /var/lib/docker being an actual directory (not a symlink to another location).
1) Stop docker:
service docker stop
. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls
/var/lib/docker/
2b) Make a backup -
tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the
/var/lib/docker
directory to your new partition:mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink:
ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv:
ls /var/lib/docker/
(note the trailing slash to
6) Start docker back up
service docker start
7) restart your containersresolve the symlink)
I believe that in this guide you'll have a good explanation.
You can change Docker's storage base directory (where container and images go) using the -g option when starting the Docker daemon.
Ubuntu/Debian: edit your
/etc/default/docker
file with the-g
option:DOCKER_OPTS="-dns 8.8.8.8 -dns 8.8.4.4 -g /mnt"
Fedora/Centos: edit
/etc/sysconfig/docker
, and add the-g
option in the other_args variable: ex.other_args="-g /var/lib/testdir"
. If there's more than one option, make sure you enclose them in " ". After a restart, (service docker restart) Docker should use the new directory.
Using a symlink is another method to change image storage.
Caution - These steps depend on your current /var/lib/docker being an actual directory (not a symlink to another location).
1) Stop docker:
service docker stop
. Verify no docker process is running ps faux
2) Double check docker really isn't running. Take a look at the current docker directory: ls
/var/lib/docker/
2b) Make a backup -
tar -zcC /var/lib docker > /mnt/pd0/var_lib_docker-backup-$(date +%s).tar.gz
3) Move the
/var/lib/docker
directory to your new partition:mv /var/lib/docker /mnt/pd0/docker
4) Make a symlink:
ln -s /mnt/pd0/docker /var/lib/docker
5) Take a peek at the directory structure to make sure it looks like it did before the mv:
ls /var/lib/docker/
(note the trailing slash to
6) Start docker back up
service docker start
7) restart your containersresolve the symlink)
edited Oct 16 '16 at 21:32
answered Aug 20 '15 at 16:56
Conrado FonsecaConrado Fonseca
20125
20125
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
add a comment |
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
what is the reason for 4)? Is it needed? In my case, I would like to have docker files to be on a mounted RAID, and not on the boot partition.
– Roman Mik
Feb 27 '17 at 16:34
add a comment |
In more recent Docker versions on Ubuntu you will edit /etc/default/daemon.json like so:
{
"data-root": "/new/location"
}
add a comment |
In more recent Docker versions on Ubuntu you will edit /etc/default/daemon.json like so:
{
"data-root": "/new/location"
}
add a comment |
In more recent Docker versions on Ubuntu you will edit /etc/default/daemon.json like so:
{
"data-root": "/new/location"
}
In more recent Docker versions on Ubuntu you will edit /etc/default/daemon.json like so:
{
"data-root": "/new/location"
}
answered Jun 15 '18 at 20:08
MattKMattK
22123
22123
add a comment |
add a comment |
To change the data
directory in docker
it needs to be run with the option -g /my/data
. In my /etc/default/docker
I set:
DOCKER_OPTS="-g /srv/docker"
See also my notes here.
To change the data
directory in lxc
I put in /etc/lxc/lxc.conf
:
lxc.lxcpath = /srv/lxc
add a comment |
To change the data
directory in docker
it needs to be run with the option -g /my/data
. In my /etc/default/docker
I set:
DOCKER_OPTS="-g /srv/docker"
See also my notes here.
To change the data
directory in lxc
I put in /etc/lxc/lxc.conf
:
lxc.lxcpath = /srv/lxc
add a comment |
To change the data
directory in docker
it needs to be run with the option -g /my/data
. In my /etc/default/docker
I set:
DOCKER_OPTS="-g /srv/docker"
See also my notes here.
To change the data
directory in lxc
I put in /etc/lxc/lxc.conf
:
lxc.lxcpath = /srv/lxc
To change the data
directory in docker
it needs to be run with the option -g /my/data
. In my /etc/default/docker
I set:
DOCKER_OPTS="-g /srv/docker"
See also my notes here.
To change the data
directory in lxc
I put in /etc/lxc/lxc.conf
:
lxc.lxcpath = /srv/lxc
answered Jul 29 '15 at 15:22
Stuart CardallStuart Cardall
1214
1214
add a comment |
add a comment |
Upgrade to Docker 1.13.0.
From the Release Notes:
- New
The storage location of the Linux volume can now be moved
add a comment |
Upgrade to Docker 1.13.0.
From the Release Notes:
- New
The storage location of the Linux volume can now be moved
add a comment |
Upgrade to Docker 1.13.0.
From the Release Notes:
- New
The storage location of the Linux volume can now be moved
Upgrade to Docker 1.13.0.
From the Release Notes:
- New
The storage location of the Linux volume can now be moved
answered Jan 26 '17 at 14:55
SnowcrashSnowcrash
14115
14115
add a comment |
add a comment |
To expand on @MattK's answer:
The Docker documentation on controlling the Docker daemon suggests that platform independent way to do this is:
edit the /etc/docker/daemon.json file to contain the line
{
"data-root": "/mnt/docker-data",
(...)
}
where /mnt/docker-data
is the directory where you want the docker images and containers to live.
Then
sudo systemctl restart docker
You can check whether it worked by running
docker info
and look for the contents of the line that start with Docker Root Dir:
.
See also https://stackoverflow.com/a/50217666/2209313 and https://unix.stackexchange.com/q/452368/36043.
New contributor
add a comment |
To expand on @MattK's answer:
The Docker documentation on controlling the Docker daemon suggests that platform independent way to do this is:
edit the /etc/docker/daemon.json file to contain the line
{
"data-root": "/mnt/docker-data",
(...)
}
where /mnt/docker-data
is the directory where you want the docker images and containers to live.
Then
sudo systemctl restart docker
You can check whether it worked by running
docker info
and look for the contents of the line that start with Docker Root Dir:
.
See also https://stackoverflow.com/a/50217666/2209313 and https://unix.stackexchange.com/q/452368/36043.
New contributor
add a comment |
To expand on @MattK's answer:
The Docker documentation on controlling the Docker daemon suggests that platform independent way to do this is:
edit the /etc/docker/daemon.json file to contain the line
{
"data-root": "/mnt/docker-data",
(...)
}
where /mnt/docker-data
is the directory where you want the docker images and containers to live.
Then
sudo systemctl restart docker
You can check whether it worked by running
docker info
and look for the contents of the line that start with Docker Root Dir:
.
See also https://stackoverflow.com/a/50217666/2209313 and https://unix.stackexchange.com/q/452368/36043.
New contributor
To expand on @MattK's answer:
The Docker documentation on controlling the Docker daemon suggests that platform independent way to do this is:
edit the /etc/docker/daemon.json file to contain the line
{
"data-root": "/mnt/docker-data",
(...)
}
where /mnt/docker-data
is the directory where you want the docker images and containers to live.
Then
sudo systemctl restart docker
You can check whether it worked by running
docker info
and look for the contents of the line that start with Docker Root Dir:
.
See also https://stackoverflow.com/a/50217666/2209313 and https://unix.stackexchange.com/q/452368/36043.
New contributor
New contributor
answered 6 hours ago
Wandering LogicWandering Logic
1012
1012
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- 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%2faskubuntu.com%2fquestions%2f631450%2fchange-data-directory-of-docker%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