default user not added to docker group, have to do su $USER?











up vote
0
down vote

favorite












I have Ubuntu 18.04. and after installing docker i added my user to docker group with the command



sudo usermod -aG docker ${USER}


and logged in



su - ${USER}


and if I check id, my user is added to docker group.



But when I reopen the terminal i cant do docker commands without sudo unless i explicitly do su ${USER}



also, I can't find docker group with the default user.
What am I missing here?










share|improve this question


















  • 2




    only do a restart.
    – gopy
    2 days ago






  • 4




    Changes to group credentials don't affect your current session. You just need to log out and log back in; it's not necessary to restart.
    – larsks
    2 days ago






  • 1




    yup! Thanks, it worked. Log out and log in. P.S. why is it necessary?
    – Sam
    2 days ago

















up vote
0
down vote

favorite












I have Ubuntu 18.04. and after installing docker i added my user to docker group with the command



sudo usermod -aG docker ${USER}


and logged in



su - ${USER}


and if I check id, my user is added to docker group.



But when I reopen the terminal i cant do docker commands without sudo unless i explicitly do su ${USER}



also, I can't find docker group with the default user.
What am I missing here?










share|improve this question


















  • 2




    only do a restart.
    – gopy
    2 days ago






  • 4




    Changes to group credentials don't affect your current session. You just need to log out and log back in; it's not necessary to restart.
    – larsks
    2 days ago






  • 1




    yup! Thanks, it worked. Log out and log in. P.S. why is it necessary?
    – Sam
    2 days ago















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have Ubuntu 18.04. and after installing docker i added my user to docker group with the command



sudo usermod -aG docker ${USER}


and logged in



su - ${USER}


and if I check id, my user is added to docker group.



But when I reopen the terminal i cant do docker commands without sudo unless i explicitly do su ${USER}



also, I can't find docker group with the default user.
What am I missing here?










share|improve this question













I have Ubuntu 18.04. and after installing docker i added my user to docker group with the command



sudo usermod -aG docker ${USER}


and logged in



su - ${USER}


and if I check id, my user is added to docker group.



But when I reopen the terminal i cant do docker commands without sudo unless i explicitly do su ${USER}



also, I can't find docker group with the default user.
What am I missing here?







linux docker






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Sam

6510




6510








  • 2




    only do a restart.
    – gopy
    2 days ago






  • 4




    Changes to group credentials don't affect your current session. You just need to log out and log back in; it's not necessary to restart.
    – larsks
    2 days ago






  • 1




    yup! Thanks, it worked. Log out and log in. P.S. why is it necessary?
    – Sam
    2 days ago
















  • 2




    only do a restart.
    – gopy
    2 days ago






  • 4




    Changes to group credentials don't affect your current session. You just need to log out and log back in; it's not necessary to restart.
    – larsks
    2 days ago






  • 1




    yup! Thanks, it worked. Log out and log in. P.S. why is it necessary?
    – Sam
    2 days ago










2




2




only do a restart.
– gopy
2 days ago




only do a restart.
– gopy
2 days ago




4




4




Changes to group credentials don't affect your current session. You just need to log out and log back in; it's not necessary to restart.
– larsks
2 days ago




Changes to group credentials don't affect your current session. You just need to log out and log back in; it's not necessary to restart.
– larsks
2 days ago




1




1




yup! Thanks, it worked. Log out and log in. P.S. why is it necessary?
– Sam
2 days ago






yup! Thanks, it worked. Log out and log in. P.S. why is it necessary?
– Sam
2 days ago














1 Answer
1






active

oldest

votes

















up vote
1
down vote













@larsks already replied to the main question in a comment, however I would like to elaborate on the implications of that change (adding your default user to the docker group).



Basically, the Docker daemon socket is owned by root:docker, so in order to use the Docker CLI commands, you need either to be in the docker group, or to prepend all docker commands by sudo.



As indicated in the documentation of Docker, it is risky to follow the first solution on your personal workstation, because this just amounts to providing the default user with root permissions without sudo-like password prompt protection. Indeed, users in the docker group are de facto root on the host. See for example this article and that one.



Instead, you may want to follow the second solution, which can be somewhat simplified by adding to your ~/.bashrc file an alias such as:



alias docker="sudo /usr/bin/docker"


Thus, docker run --rm -it debian will be automatically expanded to sudo /usr/bin/docker run --rm -it debian, thereby preserving sudo’s protection for your default user.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    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: 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
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373592%2fdefault-user-not-added-to-docker-group-have-to-do-su-user%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    @larsks already replied to the main question in a comment, however I would like to elaborate on the implications of that change (adding your default user to the docker group).



    Basically, the Docker daemon socket is owned by root:docker, so in order to use the Docker CLI commands, you need either to be in the docker group, or to prepend all docker commands by sudo.



    As indicated in the documentation of Docker, it is risky to follow the first solution on your personal workstation, because this just amounts to providing the default user with root permissions without sudo-like password prompt protection. Indeed, users in the docker group are de facto root on the host. See for example this article and that one.



    Instead, you may want to follow the second solution, which can be somewhat simplified by adding to your ~/.bashrc file an alias such as:



    alias docker="sudo /usr/bin/docker"


    Thus, docker run --rm -it debian will be automatically expanded to sudo /usr/bin/docker run --rm -it debian, thereby preserving sudo’s protection for your default user.






    share|improve this answer



























      up vote
      1
      down vote













      @larsks already replied to the main question in a comment, however I would like to elaborate on the implications of that change (adding your default user to the docker group).



      Basically, the Docker daemon socket is owned by root:docker, so in order to use the Docker CLI commands, you need either to be in the docker group, or to prepend all docker commands by sudo.



      As indicated in the documentation of Docker, it is risky to follow the first solution on your personal workstation, because this just amounts to providing the default user with root permissions without sudo-like password prompt protection. Indeed, users in the docker group are de facto root on the host. See for example this article and that one.



      Instead, you may want to follow the second solution, which can be somewhat simplified by adding to your ~/.bashrc file an alias such as:



      alias docker="sudo /usr/bin/docker"


      Thus, docker run --rm -it debian will be automatically expanded to sudo /usr/bin/docker run --rm -it debian, thereby preserving sudo’s protection for your default user.






      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        @larsks already replied to the main question in a comment, however I would like to elaborate on the implications of that change (adding your default user to the docker group).



        Basically, the Docker daemon socket is owned by root:docker, so in order to use the Docker CLI commands, you need either to be in the docker group, or to prepend all docker commands by sudo.



        As indicated in the documentation of Docker, it is risky to follow the first solution on your personal workstation, because this just amounts to providing the default user with root permissions without sudo-like password prompt protection. Indeed, users in the docker group are de facto root on the host. See for example this article and that one.



        Instead, you may want to follow the second solution, which can be somewhat simplified by adding to your ~/.bashrc file an alias such as:



        alias docker="sudo /usr/bin/docker"


        Thus, docker run --rm -it debian will be automatically expanded to sudo /usr/bin/docker run --rm -it debian, thereby preserving sudo’s protection for your default user.






        share|improve this answer














        @larsks already replied to the main question in a comment, however I would like to elaborate on the implications of that change (adding your default user to the docker group).



        Basically, the Docker daemon socket is owned by root:docker, so in order to use the Docker CLI commands, you need either to be in the docker group, or to prepend all docker commands by sudo.



        As indicated in the documentation of Docker, it is risky to follow the first solution on your personal workstation, because this just amounts to providing the default user with root permissions without sudo-like password prompt protection. Indeed, users in the docker group are de facto root on the host. See for example this article and that one.



        Instead, you may want to follow the second solution, which can be somewhat simplified by adding to your ~/.bashrc file an alias such as:



        alias docker="sudo /usr/bin/docker"


        Thus, docker run --rm -it debian will be automatically expanded to sudo /usr/bin/docker run --rm -it debian, thereby preserving sudo’s protection for your default user.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 days ago

























        answered 2 days ago









        ErikMD

        1,8231318




        1,8231318






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373592%2fdefault-user-not-added-to-docker-group-have-to-do-su-user%23new-answer', 'question_page');
            }
            );

            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







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            WPF add header to Image with URL pettitions [duplicate]