Docker image ls gives different results with sudo

Hello all, new to Docker here.

I’ve installed the latest Docker Desktop in a Ubuntu laptop:

  • Ubuntu 23.10
  • Docker Engine: 25.0.3
  • Compose: v2.24.5-desktop.1
  • Credential Helper: v0.8.1
  • Kubernetes: v1.29.1

I have it running ok. The funny bits are the different results from the “/usr/bin/docker image ls …” command to list my containers - just 1 container at this moment.

When I run the command “docker image ls …”, I get nothing. The docker services are up and running. Only AFTER I start the docker desktop application I get to see my container.

But when the same command is run by bacula (the backup software which runs under the root user), docker does not show any containers - so the backup misses my container!! Same thing happens when I run “sudo docker image ls…” Nothing is listed.

Is this the expected behaviour?

How to circumvent this and get other services running under the root user to find all containers/images in the system?

Many thanks in advance.

Cheers,

Ismael

Please share the outputs of these commands:

docker info
sudo docker info

docker context ls
sudo docker context ls

Hi Metin,

Thanks for the reply. Below is console log just after I restarted the laptop. The docker services are up. I issued the 4 commands you mentioned. Then I started the Docker Desktop, just to check any differences.

Cheers,

Ismael

(I’ve edited some lines to go around a limit for new users in the Docker Forum)

im@imcserv24:~$ sudo systemctl status docker*
[sudo] password for im:
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Wed 2024-03-13 19:28:06 GMT; 1min 13s ago
TriggeredBy: ● docker.socket
Docs: https: //docs . docker . com (**edited**)
Main PID: 1653 (dockerd)
Tasks: 10
Memory: 104.0M
CPU: 798ms
CGroup: /system.slice/docker.service
└─1653 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Mar 13 19:28:04 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:04.586600461Z" level=info msg="Starting up"
Mar 13 19:28:04 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:04.602131428Z" level=info msg="detected 127.0.0.53 nameserver, ass>
Mar 13 19:28:04 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:04.945370327Z" level=info msg="[graphdriver] using prior storage d>
Mar 13 19:28:04 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:04.949733894Z" level=info msg="Loading containers: start."
Mar 13 19:28:05 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:05.762925337Z" level=info msg="Default bridge (docker0) is assigne>
Mar 13 19:28:05 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:05.874614616Z" level=info msg="Loading containers: done."
Mar 13 19:28:05 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:05.958900720Z" level=info msg="Docker daemon" commit=061aa95 conta>
Mar 13 19:28:05 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:05.960675930Z" level=info msg="Daemon has completed initialization"
Mar 13 19:28:06 imcserv24.imc dockerd[1653]: time="2024-03-13T19:28:06.054685994Z" level=info msg="API listen on /run/docker.sock"
Mar 13 19:28:06 imcserv24.imc systemd[1]: Started docker.service - Docker Application Container Engine.

● docker.socket - Docker Socket for the API
Loaded: loaded (/lib/systemd/system/docker.socket; enabled; preset: enabled)
Active: active (running) since Wed 2024-03-13 19:27:55 GMT; 1min 24s ago
Triggers: ● docker.service
Listen: /run/docker.sock (Stream)
Tasks: 0 (limit: 19048)
Memory: 0B
CPU: 874us
CGroup: /system.slice/docker.socket

Mar 13 19:27:55 imcserv24.imc systemd[1]: Starting docker.socket - Docker Socket for the API...
Mar 13 19:27:55 imcserv24.imc systemd[1]: Listening on docker.socket - Docker Socket for the API.
im@imcserv24:~$ docker info
Client: Docker Engine - Community
Version: 25.0.4
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.5-desktop.1
Path: /usr/lib/docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: /usr/lib/docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /usr/lib/docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.21
Path: /usr/lib/docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /usr/lib/docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.0
Path: /usr/lib/docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /usr/lib/docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.4.1
Path: /usr/lib/docker/cli-plugins/docker-scout

Server:
ERROR: Cannot connect to the Docker daemon at unix:///home/im/.docker/desktop/docker.sock. Is the docker daemon running?
errors pretty printing info
im@imcserv24:~$ sudo docker info
Client: Docker Engine - Community
Version: 25.0.4
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.5-desktop.1
Path: /usr/lib/docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: /usr/lib/docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /usr/lib/docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.21
Path: /usr/lib/docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /usr/lib/docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.0
Path: /usr/lib/docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /usr/lib/docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.4.1
Path: /usr/lib/docker/cli-plugins/docker-scout

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 25.0.4
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.5.0-25-generic
Operating System: Ubuntu 23.10
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.56GiB
Name: imcserv24.imc
ID: 113b45e6-1238-445f-906d-4b510317ac64
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127 . 0 . 0 . 0/8 (**EDITED**)
Live Restore Enabled: false
im@imcserv24:~$ docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock
desktop-linux * moby Docker Desktop unix:///home/im/.docker/desktop/docker.sock
im@imcserv24:~$ sudo docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock

STARTED DOCKER DESKTOP

REPEATING SAME COMMANDS

im@imcserv24:~$ docker info
Client: Docker Engine - Community
Version: 25.0.4
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.5-desktop.1
Path: /usr/lib/docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: /usr/lib/docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /usr/lib/docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.21
Path: /usr/lib/docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /usr/lib/docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.0
Path: /usr/lib/docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /usr/lib/docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.4.1
Path: /usr/lib/docker/cli-plugins/docker-scout

Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 25.0.3
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
cgroupns
Kernel Version: 6.6.12-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.715GiB
Name: docker-desktop
ID: 5351a4fe-dfc7-46ac-9ca0-cdabd2c8b220
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127 . 0 . 0 . 0/8 (**EDITED**)
Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile
im@imcserv24:~$ sudo docker info
Client: Docker Engine - Community
Version: 25.0.4
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.12.1-desktop.4
Path: /usr/lib/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.24.5-desktop.1
Path: /usr/lib/docker/cli-plugins/docker-compose
debug: Get a shell into any image or container. (Docker Inc.)
Version: 0.0.24
Path: /usr/lib/docker/cli-plugins/docker-debug
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /usr/lib/docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.21
Path: /usr/lib/docker/cli-plugins/docker-extension
feedback: Provide feedback, right in your terminal! (Docker Inc.)
Version: v1.0.4
Path: /usr/lib/docker/cli-plugins/docker-feedback
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.0.0
Path: /usr/lib/docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /usr/lib/docker/cli-plugins/docker-sbom
scout: Docker Scout (Docker Inc.)
Version: v1.4.1
Path: /usr/lib/docker/cli-plugins/docker-scout

Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 25.0.4
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 6.5.0-25-generic
Operating System: Ubuntu 23.10
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.56GiB
Name: imcserv24.imc
ID: 113b45e6-1238-445f-906d-4b510317ac64
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127 . 0 . 0 . 0/8 (*** edited***)
Live Restore Enabled: false
im@imcserv24:~$ docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock
desktop-linux * moby Docker Desktop unix:///home/im/.docker/desktop/docker.sock
im@imcserv24:~$ sudo docker context ls
NAME TYPE DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * moby Current DOCKER_HOST based configuration unix:///var/run/docker.sock
im@imcserv24:~$

update: I wrapped your ouput in Preformated text blocks

Users have their own configuration stored in ~/.docker/config,json.

Furthermore, you have two Docker running instances: rootfull docker and Docker Desktop.

The im user context is set to use the docker engine of Docker Desktop, running inside a vm
The root user context is set to use the rootful docker engine, running on the host

As both users are not using the same docker engine, how would the they be supposed to see the came containers? Both are independent Docker Instances with their own state.

Yes, it is! :smiley:

OK, I’m new to Docker and was suspecting of 2 separate instances. But I don’t need 2 separate instances, just 1, and that should be the system/root. I’d like to have my container running in the system/root instance and manage images and containers using the Desktop.

Any pointers, suggestions or recommendations are welcome.

Thanks again.

Cheers,

Ismael

Just uninstall the docker desktop package.

If you don’t know how it’s called, you can list all packages and filter for docker:

 dpkg -l | grep docker

If the docker context for your im user is not set to the default context, you might need to set it yourself

docker context use default

I missed the last part of the sentence. This is not possible: either you use Docker Desktop with the ui and the docker engine with the vm, or you use the rootful docker and can’t use the Docker Desktop UI as a frontent for the rootful docker engine.