Search code examples
ruby-on-railsdockerdeploymentwindows-subsystem-for-linuxkamal

Error deploying rails app with Kamal: Docker login fails with exit status 256


I'm trying to deploy the rails app using Kamal, but the deployment fails during the docker login step with the following error:

    ERROR (SSHKit::Command::Failed): docker exit status: 256  
docker stdout: Nothing written  
docker stderr: WARNING! Using --password via the CLI is insecure. Use --password-stdin.  
<3>WSL (170175) ERROR: UtilAcceptVsock:250: accept4 failed 110  
Error saving credentials: error storing credentials - err: exit status 1, out: 

Environment Details

  • Rails version: 8.0
  • Ruby version: 3.3.3
  • Kamal version: 2.3.0
  • Server: Contabo VPS running Ubuntu
  • Local machine: Windows 11 with WSL2 and Docker Desktop

here is the deploy.yml

    service: writehub

image: ibunhabibu/writehub

servers:
  web:
    - 45.52.19.17

proxy:
  ssl: true
  host: writehub.cyou
  app_port: 3000

registry:
  username: ibunhabibu
  password:
    - KAMAL_REGISTRY_PASSWORD

env:
  secret:
    - RAILS_MASTER_KEY
    - POSTGRES_PASSWORD
    - POSTGRES_USER
    - GOOGLE_API
    - PIXABAY
    - OPEN_WEATHER

ssh:
  user: deployer

accessories:
  db:
    image: postgres:15
    host: 45.52.19.17
    port: "127.0.0.1:5434:5434"
    env:
      clear:
        POSTGRES_USER: 'postgres'
        POSTGRES_DB: 'writehub_production'
      secret:
        - POSTGRES_USER
        - POSTGRES_PASSWORD

Here is .env file

KAMAL_REGISTRY_PASSWORD='dckr_pat_dockercredentials'
POSTGRES_PASSWORD='Myverylongstringpswd'
POSTGRES_USER='postgres'
GOOGLE_API='GoogleApipasword'
PIXABAY='pixabaitoken'
OPEN_WEATHER='openweathertoken'

also here is .kamal/secrets

# Grab the registry password from ENV
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD
GOOGLE_API=$GOOGLE_API
PIXABAY=$PIXABAY
OPEN_WEATHER=$OPEN_WEATHER
POSTGRES_PASSWORD=$POSTGRES_PASSWORD
POSTGRES_USER=$POSTGRES_USER

# Improve security by using a password manager. Never check config/master.key into git!
RAILS_MASTER_KEY=$(cat config/master.key)

How can I resolve this error during Kamal deployment? Any help would be greatly appreciated


Solution

  • I found the answer from this link Since I'm using wsl2 ubuntu

    I navigated to the Ubuntu terminal using the following command

    ibunhabibu@DESKTOP-RG3E4I0:/mnt/c/Users/projects/rails/writehub$ cd ~
    ibunhabibu@DESKTOP-RG3E4I0:~$ cd .docker/
    ibunhabibu@DESKTOP-RG3E4I0:~/.docker$ nano config.json
    

    then I edited it from

    {
      "credsStore": "desktop.exe"
    }
    

    to

    {
      "credStore": "desktop.exe"
    }
    

    after removing s in credsStore and dotenv kamal deploy the problems solved

    Note because there is environmental variables ensure to start the kamal commands with dotenv to update the credentials i.e type

    dotenv kamal deploy