mikeizbicki / cmc-csci143

big data course materials
40 stars 76 forks source link

Unable to Connect to Docker Daemon #102

Closed jzlilili closed 2 years ago

jzlilili commented 2 years ago

I'm working on the lab for week 1 and having problems with building my Dockerfile. When I try to run

docker build -t flask-tutorial:latest .

I get the error message

Cannot connect to the Docker daemon at unix:///run/user/1171/docker.sock. Is the docker daemon running?

I've been running

systemctl --user start docker

to start Docker when I login to the lambda server, Is there something else I need to do to connect to Docker?

mikeizbicki commented 2 years ago

Somehow your docker installation is messed up, and I'm not sure exactly why. Last semester, this randomly happened to a few students, and I have yet to figure out exactly what the underlying issue is. But I did find two possible fixes:

  1. uninstall/reinstall docker
  2. see the instructions here: https://github.com/mikeizbicki/cmc-csci143/issues/13#issuecomment-774776993 which is based on the long discussion here: https://github.com/mikeizbicki/cmc-csci143/issues/7

Hopefully that helps :)

jzlilili commented 2 years ago

Number 2 fixed my issue, thank you so much!

yurynamgung commented 2 years ago

I am running into the same problem and have tried both #13 and #7 as well as uninstall/reinstalling docker. Unfortunately I am still getting the same error message

ERROR: Cannot connect to the Docker daemon at unix:///run/user/1177/docker.sockn. Is the docker daemon running?

when I run

systemctl --user status docker

I get a message that my docker is running:

docker.service - Docker Application Container Engine (Rootless)
   Loaded: loaded (/home/ynamgung/.config/systemd/user/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-01-31 01:09:03 PST; 1s ago
     Docs: https://docs.docker.com/go/rootless/
 Main PID: 63344 (rootlesskit)
   CGroup: /user.slice/user-1177.slice/user@1177.service/docker.service
           ├─63344 rootlesskit --net=vpnkit --mtu=1500 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=rsl
           ├─63353 /proc/self/exe --net=vpnkit --mtu=1500 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=
           ├─63367 vpnkit --ethernet /tmp/rootlesskit257876058/vpnkit-ethernet.sock --mtu 1500 --host-ip 0.0.0.0
           ├─63384 dockerd
           └─63425 containerd --config /run/user/1177/docker/containerd/containerd.toml --log-level info

Jan 31 01:09:03 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:03.583317988-08:00" level=warning msg="Your kernel does not support swap memory limit"
Jan 31 01:09:03 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:03.583355574-08:00" level=warning msg="Your kernel does not support CPU realtime scheduler"
Jan 31 01:09:03 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:03.583760587-08:00" level=info msg="Loading containers: start."
Jan 31 01:09:03 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:03.586622186-08:00" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: ERROR: could n
Jan 31 01:09:04 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:04.183336045-08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option 
Jan 31 01:09:04 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:04.444045634-08:00" level=info msg="Loading containers: done."
Jan 31 01:09:04 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:04.459281418-08:00" level=warning msg="Not using native diff for overlay2, this may cause degraded performance for buildi
Jan 31 01:09:04 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:04.459785922-08:00" level=info msg="Docker daemon" commit=459d0df graphdriver(s)=overlay2 version=20.10.12
Jan 31 01:09:04 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:04.459876118-08:00" level=info msg="Daemon has completed initialization"
Jan 31 01:09:04 lambda-server dockerd-rootless.sh[63344]: time="2022-01-31T01:09:04.490634681-08:00" level=info msg="API listen on /run/user/1177/docker.sock"

However when I run

docker info

I get the message that docker is not running and unable to connect:

Client:
 Context:    default
 Debug Mode: false

Server:
ERROR: Cannot connect to the Docker daemon at unix:///run/user/1177/docker.sockn. Is the docker daemon running?
errors pretty printing info
yurynamgung commented 2 years ago

I tried completely uninstalling and deleting all docker files and reinstalling again and am getting a new error now. When I run

systemctl --user status docker

I get the message that docker is running

docker.service - Docker Application Container Engine (Rootless)
   Loaded: loaded (/home/ynamgung/.config/systemd/user/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-01-31 13:34:45 PST; 6min ago
     Docs: https://docs.docker.com/go/rootless/
 Main PID: 36935 (rootlesskit)
   CGroup: /user.slice/user-1177.slice/user@1177.service/docker.service
           ├─36935 rootlesskit --net=vpnkit --mtu=1500 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=rsl
           ├─36941 /proc/self/exe --net=vpnkit --mtu=1500 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=
           ├─36951 vpnkit --ethernet /tmp/rootlesskit032790840/vpnkit-ethernet.sock --mtu 1500 --host-ip 0.0.0.0
           ├─36976 dockerd
           └─37016 containerd --config /run/user/1177/docker/containerd/containerd.toml --log-level info

Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.211197424-08:00" level=warning msg="Your kernel does not support CPU realtime scheduler"
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.211337248-08:00" level=info msg="Loading containers: start."
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.214757745-08:00" level=warning msg="Running modprobe bridge br_netfilter failed with message: modprobe: ERROR: could n
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.498083511-08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option 
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.772445616-08:00" level=info msg="Loading containers: done."
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.785575153-08:00" level=warning msg="Not using native diff for overlay2, this may cause degraded performance for buildi
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.786010732-08:00" level=info msg="Docker daemon" commit=459d0df graphdriver(s)=overlay2 version=20.10.12
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.786271869-08:00" level=info msg="Daemon has completed initialization"
Jan 31 13:34:46 lambda-server dockerd-rootless.sh[36935]: time="2022-01-31T13:34:46.818289305-08:00" level=info msg="API listen on /run/user/1177/docker.sock"
Jan 31 13:39:16 lambda-server systemd[36364]: docker.service: Current command vanished from the unit file, execution of the command list won't be resumed.

Notably, the last line of this message says Current command vanished from the unit file, execution of the command list won't be resumed.

When I run

docker info

I get that docker isn't even installed at all:

Command 'docker' not found, but can be installed with:

apt install docker.io
Please ask your administrator.
yurynamgung commented 2 years ago

I realized that I had a docker desktop app and when it was open/running, the rootless docker problems went away!

mikeizbicki commented 2 years ago

@yurynamgung The Command 'docker' not found error indicates that docker is not in your PATH. There are many possible reasons for this (and your other error messages), and so I recommend we work through them in person.

Edit: Actually, I just saw your update that you got it working. Yay! I'm a bit suspicious of the mention of a docker desktop app, however. There's no way for this to interact with the lambda server at all, and you need docker working on the lambda server. I'm just bringing this up to double check that you haven't installed it on your own machine.

yurynamgung commented 2 years ago

@yurynamgung The Command 'docker' not found error indicates that docker is not in your PATH. There are many possible reasons for this (and your other error messages), and so I recommend we work through them in person.

Edit: Actually, I just saw your update that you got it working. Yay! I'm a bit suspicious of the mention of a docker desktop app, however. There's no way for this to interact with the lambda server at all, and you need docker working on the lambda server. I'm just bringing this up to double check that you haven't installed it on your own machine.

I was also very surprised to see that this fixed the issue. I am pretty sure I installed rootless docker in the lambda server (I ran the installation curl within the lambda server) and thought that this shouldn't be interacting with my regular docker app