How to use sudo inside a docker container?

前端 未结 11 781
臣服心动
臣服心动 2020-11-30 16:17

Normally, docker containers are run using the user root. I\'d like to use a different user, which is no problem using docker\'s USER directive. But this use

11条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 16:40

    if you want to connect to container and install something
    using apt-get
    first as above answer from our brother "Tomáš Záluský"

    docker exec -u root -t -i container_id /bin/bash
    

    then try to

    RUN apt-get update or apt-get 'anything you want'

    it worked with me hope it's useful for all

提交回复
热议问题