Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to prevent Minio MC to exit in docker compose

I use Minio and Minio/MC in my docker-compose as follows:

version: '3'

services:
  minio:
    image: minio/minio
    command: server --address 0.0.0.0:9000 --console-address 0.0.0.0:9001 /data
    volumes:
      - minio-data:/data
    expose:
      - 9000
    ports:
      - "9001:9001"
    environment:
      MINIO_ROOT_USER: minio
      MINIO_ROOT_PASSWORD: minio123

  ready_minio:
    image: minio/mc
    env_file:
      - ./envs/local.env
    entrypoint: >
      /bin/sh -c "
          until (/usr/bin/mc config host add myminio http://minio:9000 minio minio123) do echo '...waiting...' &&
      sleep 1;
      done;
      /usr/bin/mc alias set myminio http://minio:9000 minio minio123;
      /usr/bin/mc admin user add myminio/ $${MINIO_ACCESS_KEY} $${MINIO_SECRET_KEY};
      /usr/bin/mc admin policy set myminio/ readwrite user=$${MINIO_ACCESS_KEY};
      /usr/bin/mc mb myminio/$${MINIO_MEDIA_FILES_BUCKET};
      /usr/bin/mc policy set public myminio/$${MINIO_MEDIA_FILES_BUCKET};
      exit 0;
      "

    depends_on:
      - minio

volumes:
  minio-data:

After all lines of entrypoint executed, ready_minio container will be exited.
I want minio/mc to remain running after the execution of entrypoint commands is finished so that I can run other commands via docker exec -it ready_minio /bin/sh or something like that.
How can I do that?

tested possible ways:
I remoded exit 0; from last line of the entrypoint and this has not solved the problem.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want the container to continue running, then you need to provide a command that will not exit. A common option for "do nothing, forever" is the sleep inf command:

ready_minio:
  image: minio/mc
  env_file:
    - ./envs/local.env
  entrypoint: >
    /bin/sh -c "
        until (/usr/bin/mc config host add myminio http://minio:9000 minio minio123) do echo '...waiting...' &&
    sleep 1;
    done;
    /usr/bin/mc alias set myminio http://minio:9000 minio minio123;
    /usr/bin/mc admin user add myminio/ $${MINIO_ACCESS_KEY} $${MINIO_SECRET_KEY};
    /usr/bin/mc admin policy set myminio/ readwrite user=$${MINIO_ACCESS_KEY};
    /usr/bin/mc mb myminio/$${MINIO_MEDIA_FILES_BUCKET};
    /usr/bin/mc policy set public myminio/$${MINIO_MEDIA_FILES_BUCKET};
    exec sleep inf;
    "
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading