basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
11.69k stars 474 forks source link

Fedora docker daemon not running on kamal deploy #1201

Open acetousk opened 3 weeks ago

acetousk commented 3 weeks ago

On a fresh fedora instance, and a working kamal project, I ran

kamal init

Updated config/deploy.yml to my docker hub repo / user Set working KAMAL_REGISTRY_PASSWORD After running

kamal setup

I get

  Finished all in 302.2 seconds
Releasing the deploy lock...
  Finished all in 303.1 seconds
  ERROR (SSHKit::Command::Failed): Exception while executing on host myip: docker exit status: 1
docker stdout: Nothing written
docker stderr: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Then to continue using kamal I have to manually ssh into my machine and run the following to keep docker running despite restarts

systemctl start docker
systemctl enable docker

Problem: Should have started the docker daemon automatically upon install for future commands to work

fidalgo commented 3 weeks ago

ERROR (SSHKit::Command::Failed): Exception while executing on host myip: docker exit status: 1

The error seems to be related with SSH not docker, are you able to SSH into the machine?

acetousk commented 2 weeks ago

No ssh works fine because when I ran into the same problem again, the only way to fix it was to ssh into the server and run the systemctl commands above. Then the ssh worked fine

I believe that message means that the docker service exit with a status of 1 because the docker service wasn't running.

fidalgo commented 2 weeks ago

Ah ok I see your point. You should remember that Kamal is a deployment tool, not a system configuration. Not sure if this is the responsibility of Kamal (I'm just a regular user), because those commands are not universal in Linux, so Kamal would have to query for the OS and then run the adequate commands to enable docker daemon at startup. In my case, I installed everything I need and secured the system and then used kamal to deploy and run the containers.

acetousk commented 2 weeks ago

I understand that it's not a system configuration, but it says that all you need to do is point to an ip you can access over ssh, and it'll install docker and do the rest of the deployment.

When kamal installs docker (see below) on debian and ubuntu, docker will automatically start the docker daemon post install. However because fedora and rhel by default don't start the docker daemon, it would be an impactful low hanging fruit change to just start the docker daemon with systemctl if it isn't started.

kamal setup
  INFO [cc2b9321] Running /usr/bin/env mkdir -p .kamal on myip
  INFO [cc2b9321] Finished in 0.817 seconds with exit status 0 (successful).
Acquiring the deploy lock...
warning: could not open directory 'db/postgres/data/': Permission denied
Ensure Docker is installed...
  INFO [29053175] Running docker -v on myip
  INFO [29053175] Finished in 0.124 seconds with exit status 127 (failed).
  INFO [b5c933cb] Running [ "${EUID:-$(id -u)}" -eq 0 ] || command -v sudo >/dev/null || command -v su >/dev/null on myip
  INFO [b5c933cb] Finished in 0.131 seconds with exit status 0 (successful).
  INFO Missing Docker on myip. Installing…
  INFO [63679fdf] Running /usr/bin/env sh -c 'curl -fsSL https://get.docker.com || wget -O - https://get.docker.com || echo "exit 1"' | sh on myip
  INFO [63679fdf] Finished in 43.739 seconds with exit status 0 (successful).