2017-08-30 104 views
0

當嘗試通過carrierwave上傳文件時出現錯誤Excon :: Error :: Socket(getaddrinfo:名稱或服務未知(SocketError))fog- aws到minio。無法通過carrierwave fog-aws上傳文件到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初始化

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 
+0

也許看到你的服務器日誌將有助於理解這個問題。 –

+0

在日誌中只有一個錯誤。 Excon :: Error :: Socket(getaddrinfo:名稱或服務未知(SocketError)) –

+0

我相信當dns無法解析時會出現錯誤,也許localhost在該上下文中沒有定義?您可以嘗試明確設置IP,以便使用端點值「http://127.0.0.1:9000」。 – geemus

回答

0

您Carrierwave搬運工容器應指向你的情況下更改服務DNS裏面應該工作

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