Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker permission denied on login and everything i try

I am new to docker and I get permission denied on everything i try or not found. I cannot install anything to any docker container and nothing seems to work. I have had others look and no one seems to know why every docker container fails to work for me. Here is an example:

sudo docker run -it ubuntu
[sudo] password for user: 
bash: /root/.bashrc: Permission denied
root@ac9449598270:/# vi test.txt
bash: vi: command not found
root@ac9449598270:/# apt-get install vim
W: Unable to read /etc/apt/apt.conf.d/01-vendor-ubuntu - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/01autoremove - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/01autoremove-kernels - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/70debconf - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-autoremove-suggests - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-clean - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-gzip-indexes - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-no-languages - open (13: Permission denied)
E: Error reading the CPU table 

Edit:

running docker with sudo produces the following error:

docker run -it ubuntu
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

Edit 2: I am on PopOS. Its on a system 76 machine. I have tried running as root and that doesnt help.

Edit 3: typing groups shows

groups
user adm sudo

So as per @alex067 suggestion I added the docker group with the following commands

sudo groupadd docker
sudo usermod -a -G docker user

After running the commands I now have a docker group and I have been added to the group. The error is the following

sudo docker run -it ubuntu
bash: /root/.bashrc: Permission denied
root@a7a80c8426db:/# apt update
W: Unable to read /etc/apt/apt.conf.d/01-vendor-ubuntu - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/01autoremove - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/01autoremove-kernels - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/70debconf - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-autoremove-suggests - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-clean - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-gzip-indexes - open (13: Permission denied)
W: Unable to read /etc/apt/apt.conf.d/docker-no-languages - open (13: Permission denied)
E: Error reading the CPU table
root@a7a80c8426db:/# 

I also tried to restart docker and receive the following error

sudo systemctl restart docker
Failed to restart docker.service: Unit docker.service not found.
like image 438
CodeGuyRoss Avatar asked Jan 07 '20 17:01

CodeGuyRoss


1 Answers

It looks like your user on your host machine doesn't have permission to use the docker engine (or socket? not sure the difference).

You can verify this using group to view which groups your user is a part of. You should see "docker" as one of the groups.

If not, that is your problem.

You can add your user to the docker group (which provides permissions to use the docker engine), by doing

usermod -a -G docker my_user

This will add the docker group as secondary group to your user.

After that, it may be a good idea to restart the docker engine, with:

sudo systemctl restart docker
like image 119
alex067 Avatar answered Sep 28 '22 10:09

alex067