无法通过carrierwave fog-aws将文件上传到minio(docker-compose)

时间:2017-08-30 00:30:53

标签: ruby-on-rails carrierwave fog minio

尝试通过carrierwave fog-aws上传文件到minio时,出现错误Excon :: Error :: Socket(getaddrinfo:名称或服务未知(SocketError))。

Docker撰写

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

1 个答案:

答案 0 :(得分:0)

您的Docker容器中的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