basecamp / kamal

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

ERROR (Errno::ENOENT): No such file or directory - docker #717

Closed mbajur closed 6 months ago

mbajur commented 7 months ago

Hey,

I'm trying to play with Kamal for production setup of one of my clients and i got stuck on kamal setup. Basically, right after docker login step, command throws ERROR (Errno::ENOENT): No such file or directory - docker error and i'm not sure what to do about it.

Command output:

(...)
Log into image registry...
  INFO [9b53ce42] Running docker login ghcr.io -u [REDACTED] -p [REDACTED] as mbajur@localhost
 DEBUG [9b53ce42] Command: docker login ghcr.io -u [REDACTED] -p [REDACTED]
  Finished all in 0.1 seconds
Releasing the deploy lock...
DEBUG [6fcbbd18] Running /usr/bin/env rm .kamal/lock-xxx/details && rm -r .kamal/lock-xxx on xxx
 DEBUG [6fcbbd18] Command: /usr/bin/env rm .kamal/lock-xxx/details && rm -r .kamal/lock-xxx
 DEBUG [6fcbbd18] Finished in 0.116 seconds with exit status 0 (successful).
  Finished all in 4.6 seconds
  ERROR (Errno::ENOENT): No such file or directory - docker
/Users/mbajur/.rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/open3.rb:222:in `spawn'
/Users/mbajur/.rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/open3.rb:222:in `popen_run'
/Users/mbajur/.rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/open3.rb:103:in `popen3'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/backends/local.rb:44:in `execute_command'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/backends/abstract.rb:148:in `block in create_command_and_execute'
<internal:kernel>:90:in `tap'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/backends/abstract.rb:148:in `create_command_and_execute'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/backends/abstract.rb:80:in `execute'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/registry.rb:4:in `block in login'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/backends/abstract.rb:31:in `run'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/sshkit-1.22.0/lib/sshkit/dsl.rb:10:in `run_locally'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/registry.rb:4:in `login'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:116:in `invoke'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/main.rb:26:in `block (2 levels) in deploy'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/base.rb:83:in `mutating'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/main.rb:22:in `block in deploy'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/base.rb:75:in `print_runtime'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/main.rb:21:in `deploy'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/main.rb:13:in `block (2 levels) in setup'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/base.rb:92:in `mutating'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/main.rb:5:in `block in setup'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/base.rb:75:in `print_runtime'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/lib/kamal/cli/main.rb:4:in `setup'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'
/Users/mbajur/.rvm/gems/ruby-3.2.0/gems/kamal-1.3.1/bin/kamal:9:in `<top (required)>'
/Users/mbajur/.rvm/gems/ruby-3.2.0/bin/kamal:25:in `load'
/Users/mbajur/.rvm/gems/ruby-3.2.0/bin/kamal:25:in `<main>'
/Users/mbajur/.rvm/gems/ruby-3.2.0/bin/ruby_executable_hooks:22:in `eval'
/Users/mbajur/.rvm/gems/ruby-3.2.0/bin/ruby_executable_hooks:22:in `<main>'

deploy.yml file

# Name of your application. Used to uniquely configure containers.
service: xxx

# Name of the container image.
image: xxx/xxx

volumes:
  - "/storage:/rails/storage"

# Deploy to these servers.
servers:
  web:
    hosts:
      - xxx
    labels:
      traefik.http.routers.imagebinary.rule: Host(`xxx`)
      traefik.http.routers.imagebinary_secure.entrypoints: websecure
      traefik.http.routers.imagebinary_secure.rule: Host(`xxx`)
      traefik.http.routers.imagebinary_secure.tls: true
      traefik.http.routers.imagebinary_secure.tls.certresolver: letsencrypt
    options:
      network: "private"
  job:
    hosts:
      - xxx
    cmd: bundle exec sidekiq
    options:
      network: "private"

# Credentials for your image host.
registry:
  # Specify the registry server, if you're not using Docker Hub
  server: ghcr.io
  username: mbajur

  # Always use an access token rather than real password when possible.
  password:
    - KAMAL_REGISTRY_PASSWORD

# Inject ENV variables into containers (secrets come from .env).
# Remember to run `kamal env push` after making changes!
env:
  clear:
    HOSTNAME: xxx
    DB_HOST: xxx
    RAILS_SERVE_STATIC_FILES: true
    RAILS_LOG_TO_STDOUT: true
  secret:
    # - KAMAL_REGISTRY_PASSWORD
    # - RAILS_MASTER_KEY
    - POSTGRES_PASSWORD

# Use a different ssh user than root
ssh:
  user: app

I'm on MacOS Ventura 13.6.1 / ruby 3.2.0

mbajur commented 7 months ago

It turned out to be caused by the fact I'm not able to run a following command: $ /usr/bin/env docker and as a temporary solution, i was able to make kamal setup pass by making sure export PATH=$PATH:~/.docker/bin is in my ~/.bashrc file and running $ source ~/.bashrc before calling kamal setup but that's not ideal and i would love to know how to make docker command accessible through /usr/bin/env. Any tips much appreciated but if you don't want to bother - feel free to close the issue :)

morgoth commented 7 months ago

@mbajur This is explained in the documentation, see https://kamal-deploy.org/docs/configuration#using-a-different-ssh-user-than-root

Can you close the issue if this solves your problem?

mbajur commented 6 months ago

Hmm i don't think that's the case as the issue is happening on my local machine. I had to use $ source on my laptop, not on the server.

wenderjean commented 6 months ago

@mbajur This error is related to your local system. I described a similar scenario here. The scenario is similar because Kamal tries to execute docker locally in order to log in the registry.

mbajur commented 6 months ago

i THINK i managed to fix that by using system docker setup instead of user docker setup in docker dashboard settings thing. Probably not the ideal solution but working for me so far so i'm gonna close that. Thanks for your replies!