4

I build and run an Docker Container using sudo privilege to do so I ran bellow commands

This command to build the container and its build successfully.

sudo docker build -t getting-started .

After that I ran the docker container using bellow command

sudo docker run -dp 3000:3000 getting-started

After running the docker container everything is running fine and I am able to see my container when I ran bellow command

sudo docker ps

But the problem is I am not able to see my container that I just built and ran in my Docker Desktop.

Note: If I build and run the docker container without sudo privilege then I am able to see the container in Docker Desktop.

So now what should I do to manage my containers using Docker Desktop those are build and running using sudo privilege.

Saiful Islam
  • 1,151
  • 13
  • 22
  • Having the exact same problem. Should also notice that "docker ps" and "sudo docker ps" do not show the same containers. Those created without the sudo privilege only show under "docker ps" and those created with the sudo privilege only show under "sudo docker ps". I have not given sudo privileges to docker by default due to security concerns. – don_jon Jun 27 '22 at 17:44
  • Yes. Now just waiting for an authentic answer from someone expert. – Saiful Islam Jun 28 '22 at 09:22

3 Answers3

0

i am facing the same problems for a while and didn't get anything that worked for me as of yet but maybe in your case if you can enable docker to run in rootless mode or add your user to docker group enable privileges to enable the user to use docker with out sudo it may also work for the docker desktop to access those images in the sudo mode. try https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo https://docs.docker.com/engine/install/linux-postinstall/

the other solution i thought up is to make the docker desktop use the context you are using for the docker engine which is the default not the desktop-linux it will create when its starting up maybe that will enable it to read the past containers you were using

or another solution is to run the docker desktop in sudo mode i dont know how to do that as of yet but its worth a shot if you can find out how

Sol Tig
  • 11
  • 5
0

if your build successed you can run

docker ps -a 

to see all the working and stoped containers

and you can run

docker logs --tail=50 container-name

so you can see the container logs and start fixing the issue

Salah Ben Bouzid
  • 381
  • 4
  • 10
  • 1
    Thanks for your effort. Yes I can manage all of docker things using my terminal. But my point is I am not able to utilize my workflow using docker desktop app. – Saiful Islam Jun 27 '22 at 07:42
0

Just don't use sudo when you create the container.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 23 '23 at 13:01