Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.7K
Views
docker-compose: cómo usar minio dentro y fuera de la red docker

Tengo el siguiente docker-compose.yml para ejecutar un entorno local para mi aplicación Laravel.

 version: '3' services: app: build: context: . dockerfile: .docker/php/Dockerfile ports: - 80:80 - 443:443 volumes: - .:/var/www:delegated environment: AWS_ACCESS_KEY_ID: minio_access_key AWS_SECRET_ACCESS_KEY: minio_secret_key AWS_BUCKET: Bucket AWS_ENDPOINT: http://s3:9000 links: - database - s3 database: image: mariadb:10.3 ports: - 63306:3306 environment: MYSQL_ROOT_PASSWORD: secret s3: image: minio/minio ports: - "9000:9000" volumes: - ./storage/minio:/data environment: MINIO_ACCESS_KEY: minio_access_key MINIO_SECRET_KEY: minio_secret_key command: server /data

Como puede ver, uso minio como almacenamiento compatible con AWS S3. Esto funciona muy bien, pero cuando genero una url para un archivo ( Storage::disk('s3')->url('some-file.txt') ) obviamente obtengo una url como esta http://s3:9000/Bucket/some-file.txt que no funciona fuera de la red de Docker.

Ya intenté configurar AWS_ENDPOINT en http://127.0.0.1:9000 pero Laravel no puede conectarse al servidor Minio...

¿Hay alguna manera de configurar Docker/Laravel/Minio para generar direcciones URL a las que se pueda acceder dentro y fuera de la red de Docker?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

¿Qué hay de la dirección vinculante? (no probado)

 ... s3: image: minio/minio ports: - "9000:9000" volumes: - ./storage/minio:/data environment: MINIO_ACCESS_KEY: minio_access_key MINIO_SECRET_KEY: minio_secret_key command: server --address 0.0.0.0:9000 /data

over 4 years ago · Santiago Trujillo Report

0

Amplié las soluciones en esta pregunta para crear una solución que me funcione tanto en un localhost como en un servidor con un dns accesible.

La solución localhost es esencialmente la solución descrita anteriormente.

Crear mapeo de host localhost

 sudo echo "127.0.0.1 my-minio-localhost-alias" >> /etc/hosts

Establezca HOSTNAME, use 'my-minio-localhost-alias' para localhost

 export HOSTNAME=my-minio-localhost-alias

Crear hola.txt

 Hello from Minio!

Crear docker-compose.yml

Este archivo de redacción contiene los siguientes contenedores:

  • minio: servicio minio
  • minio-mc: herramienta de línea de comandos para inicializar contenido
  • s3-client: herramienta de línea de comandos para generar URL prefirmadas
 version: '3.7' networks: mynet: services: minio: container_name: minio image: minio/minio ports: - published: 9000 target: 9000 command: server /data networks: mynet: aliases: # For localhost access, add the following to your /etc/hosts # 127.0.0.1 my-minio-localhost-alias # When accessing the minio container on a server with an accessible dns, use the following - ${HOSTNAME} # When initializing the minio container for the first time, you will need to create an initial bucket named my-bucket. minio-mc: container_name: minio-mc image: minio/mc depends_on: - minio volumes: - "./hello.txt:/tmp/hello.txt" networks: mynet: s3-client: container_name: s3-client image: amazon/aws-cli environment: AWS_ACCESS_KEY_ID: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin depends_on: - minio networks: mynet:

Inicie el contenedor minio

 docker-compose up -d minio

Crea un cubo en minio y carga un archivo

 docker-compose run minio-mc mc config host add docker http://minio:9000 minioadmin minioadmin docker-compose run minio-mc mb docker/my-bucket docker-compose run minio-mc mc cp /tmp/hello.txt docker/my-bucket/foo.txt

Cree una URL prefirmada a la que se pueda acceder dentro Y fuera de la red acoplable

 docker-compose run s3-client --endpoint-url http://${HOSTNAME}:9000 s3 presign s3://my-bucket/hello.txt
over 4 years ago · Santiago Trujillo Report

0

Agregar el alias "s3" a mi archivo de hosts local no funcionó. Pero vincular explícitamente los puertos a 127.0.0.1 funcionó de maravilla:

 s3: image: minio/minio:RELEASE.2022-02-05T04-40-59Z restart: "unless-stopped" volumes: - s3data:/data environment: MINIO_ROOT_USER: minio MINIO_ROOT_PASSWORD: minio123 # Allow all incoming hosts to access the server by using 0.0.0.0 command: server --address 0.0.0.0:9000 --console-address ":9001" /data ports: # Bind explicitly to 127.0.0.1 - "127.0.0.1:9000:9000" - "9001:9001" healthcheck: test: ["CMD", "curl", "-f", "http://127.0.0.1:9000/minio/health/live"] interval: 30s timeout: 20s retries: 3
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!