Change Docker Root Dir on Red Hat Linux?

The name of the pictureThe name of the pictureThe name of the pictureClash 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







share|improve this question

























    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







    share|improve this question























      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







      share|improve this question













      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









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 1 at 13:33









      Jeff Schaller

      30.8k846104




      30.8k846104









      asked Jun 28 at 7:24









      M. Max

      182




      182




















          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.






          share|improve this answer

















          • 1




            You'll also want to run: semanage fcontext -a -e /var/lib/docker /data/docker
            – jsbillings
            Jun 28 at 23:36











          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          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






























          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.






          share|improve this answer

















          • 1




            You'll also want to run: semanage fcontext -a -e /var/lib/docker /data/docker
            – jsbillings
            Jun 28 at 23:36















          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.






          share|improve this answer

















          • 1




            You'll also want to run: semanage fcontext -a -e /var/lib/docker /data/docker
            – jsbillings
            Jun 28 at 23:36













          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.






          share|improve this answer













          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.







          share|improve this answer













          share|improve this answer



          share|improve this answer











          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













          • 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













           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)