Change Docker Root Dir on Red Hat Linux?

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I have a little problem. I have a brand new Red Hat Linux Server and I installed Docker CE for CentOS/Red Hat with the official repositories for Docker CE. Now I see that docker creates the container under /var/lib/docker, but my problem is that I use an extra partition for my data under /data/docker. How can I change the default root directory for Docker in CentOS/Red Hat?
I tried a few HOWTOs but I get the same problem. I canâÂÂt find the configuration. For example, I search for the following files:
/etc/default/docker(I think only for Debian/Ubuntu)/etc/systemd/system/docker.service.d/override.conf(I can't find on my system)/etc/docker/daemon.json(I can't find on my system)
If I get the docker info I see:
Docker Root Dir: /var/lib/docker
linux directory docker
add a comment |Â
up vote
3
down vote
favorite
I have a little problem. I have a brand new Red Hat Linux Server and I installed Docker CE for CentOS/Red Hat with the official repositories for Docker CE. Now I see that docker creates the container under /var/lib/docker, but my problem is that I use an extra partition for my data under /data/docker. How can I change the default root directory for Docker in CentOS/Red Hat?
I tried a few HOWTOs but I get the same problem. I canâÂÂt find the configuration. For example, I search for the following files:
/etc/default/docker(I think only for Debian/Ubuntu)/etc/systemd/system/docker.service.d/override.conf(I can't find on my system)/etc/docker/daemon.json(I can't find on my system)
If I get the docker info I see:
Docker Root Dir: /var/lib/docker
linux directory docker
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I have a little problem. I have a brand new Red Hat Linux Server and I installed Docker CE for CentOS/Red Hat with the official repositories for Docker CE. Now I see that docker creates the container under /var/lib/docker, but my problem is that I use an extra partition for my data under /data/docker. How can I change the default root directory for Docker in CentOS/Red Hat?
I tried a few HOWTOs but I get the same problem. I canâÂÂt find the configuration. For example, I search for the following files:
/etc/default/docker(I think only for Debian/Ubuntu)/etc/systemd/system/docker.service.d/override.conf(I can't find on my system)/etc/docker/daemon.json(I can't find on my system)
If I get the docker info I see:
Docker Root Dir: /var/lib/docker
linux directory docker
I have a little problem. I have a brand new Red Hat Linux Server and I installed Docker CE for CentOS/Red Hat with the official repositories for Docker CE. Now I see that docker creates the container under /var/lib/docker, but my problem is that I use an extra partition for my data under /data/docker. How can I change the default root directory for Docker in CentOS/Red Hat?
I tried a few HOWTOs but I get the same problem. I canâÂÂt find the configuration. For example, I search for the following files:
/etc/default/docker(I think only for Debian/Ubuntu)/etc/systemd/system/docker.service.d/override.conf(I can't find on my system)/etc/docker/daemon.json(I can't find on my system)
If I get the docker info I see:
Docker Root Dir: /var/lib/docker
linux directory docker
edited Jul 1 at 13:33
Jeff Schaller
30.8k846104
30.8k846104
asked Jun 28 at 7:24
M. Max
182
182
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Stop all running docker containers and then docker daemon. Move "/var/lib/docker" directory to the place where you want to have this data.
For you it would be:
mv -r /var/lib/docker /data/
and then create symlink for this docker directory in /var/lib path:
ln -s /data/docker /var/lib/
Start docker daemon and containers.
1
You'll also want to run:semanage fcontext -a -e /var/lib/docker /data/docker
â jsbillings
Jun 28 at 23:36
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Stop all running docker containers and then docker daemon. Move "/var/lib/docker" directory to the place where you want to have this data.
For you it would be:
mv -r /var/lib/docker /data/
and then create symlink for this docker directory in /var/lib path:
ln -s /data/docker /var/lib/
Start docker daemon and containers.
1
You'll also want to run:semanage fcontext -a -e /var/lib/docker /data/docker
â jsbillings
Jun 28 at 23:36
add a comment |Â
up vote
2
down vote
accepted
Stop all running docker containers and then docker daemon. Move "/var/lib/docker" directory to the place where you want to have this data.
For you it would be:
mv -r /var/lib/docker /data/
and then create symlink for this docker directory in /var/lib path:
ln -s /data/docker /var/lib/
Start docker daemon and containers.
1
You'll also want to run:semanage fcontext -a -e /var/lib/docker /data/docker
â jsbillings
Jun 28 at 23:36
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Stop all running docker containers and then docker daemon. Move "/var/lib/docker" directory to the place where you want to have this data.
For you it would be:
mv -r /var/lib/docker /data/
and then create symlink for this docker directory in /var/lib path:
ln -s /data/docker /var/lib/
Start docker daemon and containers.
Stop all running docker containers and then docker daemon. Move "/var/lib/docker" directory to the place where you want to have this data.
For you it would be:
mv -r /var/lib/docker /data/
and then create symlink for this docker directory in /var/lib path:
ln -s /data/docker /var/lib/
Start docker daemon and containers.
answered Jun 28 at 7:36
mariaczi
42915
42915
1
You'll also want to run:semanage fcontext -a -e /var/lib/docker /data/docker
â jsbillings
Jun 28 at 23:36
add a comment |Â
1
You'll also want to run:semanage fcontext -a -e /var/lib/docker /data/docker
â jsbillings
Jun 28 at 23:36
1
1
You'll also want to run:
semanage fcontext -a -e /var/lib/docker /data/dockerâ jsbillings
Jun 28 at 23:36
You'll also want to run:
semanage fcontext -a -e /var/lib/docker /data/dockerâ jsbillings
Jun 28 at 23:36
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452368%2fchange-docker-root-dir-on-red-hat-linux%23new-answer', 'question_page');
);
Post as a guest
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
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
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