2

I started to learn docker recently. After I install the docker,and I input sudo docker run hello-world to check does it install successfully, it shows as the title. By the way,when I input docker version, it shows the version that I installed.

jwvh
  • 50,871
  • 7
  • 38
  • 64
李jungle
  • 21
  • 1
  • 1
  • 2
  • 2
    Be aware docker cli != docker daemon, when you ask docker for version - you're working with cli, to connect to docker daemon you have to start daemon first – stck Mar 16 '21 at 08:03

3 Answers3

3

Sounds like you've only installed docker but haven't started the docker daemon. On most distros, you can use systemctl:

sudo systemctl start docker   # to start the service
sudo systemctl enable docker  # to autostart on boot
tdy
  • 36,675
  • 19
  • 86
  • 83
  • If I run `sudo systemctl status docker` it tells me the daemon is already running: `● docker.service - Docker Application Container Engine Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2022-10-25 16:26:12 PDT; 5min ago ` but yet when I run the docker helloworld command I get the same error. – Raleigh L. Oct 25 '22 at 23:32
0

I would suggest sometimes add more permissions to /var/run/docker.sock, like that:

chmod 666 /var/run/docker.sock
Vova
  • 3,117
  • 2
  • 15
  • 23
0

First
Check if you have the daemon :

sudo systemctl list-units | grep -i docker

If you had, check the status:

sudo systemctl status docker

Second Start and enable it as @tdy answered.

sudo systemctl start docker   # to start the service
sudo systemctl enable docker  # to autostart on boot

if you did not have it check Configure and troubleshoot the Docker daemon for more.

Shakiba Moshiri
  • 21,040
  • 2
  • 34
  • 44
  • The code doesnt run, because my ubuntu only can run sysvinit codes rather than systemd, could you write another form of the codes – 李jungle Mar 16 '21 at 11:40