0

Have error Excon::Error::Socket (getaddrinfo: Name or service not known (SocketError)) when try to upload file through carrierwave fog-aws to minio.

Docker compose

version: '3'
services:
  minio:
    image: minio/minio
    deploy:
      resources:
        limits:
          memory: 256m
    volumes:
      - 'minio:/var/lib/minio'
    environment:
      - "MINIO_ACCESS_KEY=development"
      - "MINIO_SECRET_KEY=development"
    ports:
      - "9000:9000"
    command: server /export
  rails:
    build: .
    command: bash -c 'rm -f /test/tmp/pids/server.pid && bundle && bundle exec rails s -p 3000 -b 0.0.0.0'
    volumes:
      - .:/test
    ports:
      - "3000:3000"
    depends_on:
      - minio
volumes:
  minio:

Carrierwave initializer

CarrierWave.configure do |config|
  config.fog_provider = 'fog/aws'
  config.fog_credentials = {
      provider:              'AWS',
      aws_access_key_id:     'development',
      aws_secret_access_key: 'development',
      region:                'us-east-1',
      host:                  'minio',
      endpoint:              'http://localhost:9000'
  }
  config.fog_directory  = 'test'
  config.fog_public     = false
  # config.fog_attributes = { cache_control: "public, max-age=#{365.day.to_i}" } # optional, defaults to {}
end
  • maybe seeing your server log would help understanding this issue. – Fabrizio Bertoglio Aug 30 '17 at 03:50
  • in the log only one error. Excon::Error::Socket (getaddrinfo: Name or service not known (SocketError)) – Vitaly Igorevich Aug 30 '17 at 10:59
  • I believe that error will come up when dns can not be resolved, maybe localhost is not defined in that context? You might try explicitly setting the ip, so using endpoint value of `http://127.0.0.1:9000`. – geemus Aug 31 '17 at 14:26
  • I forgot about internal addresses in the docker. instead http://localhost:9000 i must use http://minio:9000. Problem solved. – Vitaly Igorevich Sep 01 '17 at 11:00

2 Answers2

0

You Carrierwave inside docker container should point to the service DNS in your case following change should work

CarrierWave.configure do |config|
  config.fog_provider = 'fog/aws'
  config.fog_credentials = {
      provider:              'AWS',
      aws_access_key_id:     'development',
      aws_secret_access_key: 'development',
      region:                'us-east-1',
      host:                  'minio',
      endpoint:              'http://minio:9000'
  }
  config.fog_directory  = 'test'
  config.fog_public     = false
  # config.fog_attributes = { cache_control: "public, max-age=#{365.day.to_i}" } # optional, defaults to {}
end
Harshavardhana
  • 1,400
  • 8
  • 17
0

Adding to previous answer you should also add 'path_style' => true to your config