From bd9cdcf379f5bdc5b5f7fb2f4bedb1f8bcfe4c8f Mon Sep 17 00:00:00 2001 From: Paul Trunk <33650762+ptrunk@users.noreply.github.com> Date: Tue, 9 Jan 2018 06:16:25 +0100 Subject: [PATCH] Add custom secret names for Docker (#5355) --- Dockerfile | 2 ++ Dockerfile.dev | 2 ++ Dockerfile.release | 2 ++ dockerscripts/docker-entrypoint.sh | 14 +++++++------- docs/docker/README.md | 11 +++++++++++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 12064b2f1..348e401e6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,8 @@ ENV GOPATH /go ENV PATH $PATH:$GOPATH/bin ENV CGO_ENABLED 0 ENV MINIO_UPDATE off +ENV MINIO_ACCESS_KEY_FILE=access_key \ + MINIO_SECRET_KEY_FILE=secret_key WORKDIR /go/src/github.com/minio/ diff --git a/Dockerfile.dev b/Dockerfile.dev index 541b64848..00120db39 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -6,6 +6,8 @@ ENV GOPATH /go ENV PATH $PATH:$GOPATH/bin ENV CGO_ENABLED 0 ENV MINIO_UPDATE off +ENV MINIO_ACCESS_KEY_FILE=access_key \ + MINIO_SECRET_KEY_FILE=secret_key WORKDIR /go/src/github.com/minio/ diff --git a/Dockerfile.release b/Dockerfile.release index 472a3c164..4c68dce8b 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -5,6 +5,8 @@ MAINTAINER Minio Inc COPY dockerscripts/docker-entrypoint.sh dockerscripts/healthcheck.sh /usr/bin/ ENV MINIO_UPDATE off +ENV MINIO_ACCESS_KEY_FILE=access_key \ + MINIO_SECRET_KEY_FILE=secret_key RUN \ apk add --no-cache ca-certificates && \ diff --git a/dockerscripts/docker-entrypoint.sh b/dockerscripts/docker-entrypoint.sh index fbb813ea1..36aa77d70 100755 --- a/dockerscripts/docker-entrypoint.sh +++ b/dockerscripts/docker-entrypoint.sh @@ -24,15 +24,15 @@ fi ## Look for docker secrets in default documented location. docker_secrets_env() { - local MINIO_ACCESS_KEY_FILE="/run/secrets/access_key" - local MINIO_SECRET_KEY_FILE="/run/secrets/secret_key" + local ACCESS_KEY_FILE="/run/secrets/$MINIO_ACCESS_KEY_FILE" + local SECRET_KEY_FILE="/run/secrets/$MINIO_SECRET_KEY_FILE" - if [ -f $MINIO_ACCESS_KEY_FILE -a -f $MINIO_SECRET_KEY_FILE ]; then - if [ -f $MINIO_ACCESS_KEY_FILE ]; then - export MINIO_ACCESS_KEY="$(cat "$MINIO_ACCESS_KEY_FILE")" + if [ -f $ACCESS_KEY_FILE -a -f $SECRET_KEY_FILE ]; then + if [ -f $ACCESS_KEY_FILE ]; then + export MINIO_ACCESS_KEY="$(cat "$ACCESS_KEY_FILE")" fi - if [ -f $MINIO_SECRET_KEY_FILE ]; then - export MINIO_SECRET_KEY="$(cat "$MINIO_SECRET_KEY_FILE")" + if [ -f $SECRET_KEY_FILE ]; then + export MINIO_SECRET_KEY="$(cat "$SECRET_KEY_FILE")" fi fi } diff --git a/docs/docker/README.md b/docs/docker/README.md index b48b4ace5..fb6947814 100644 --- a/docs/docker/README.md +++ b/docs/docker/README.md @@ -73,6 +73,17 @@ docker service create --name="minio-service" --secret="access_key" --secret="sec Read more about `docker service` [here](https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/) +#### Minio Custom Access and Secret Key files +To use other secret names follow the instuctions above and replace `access_key` and `secret_key` with your custom names (e.g. `my_secret_key`,`my_custom_key`). Run your service with +``` +docker service create --name="minio-service" \ + --secret="my_access_key" \ + --secret="my_secret_key" \ + --env="MINIO_ACCESS_KEY_FILE=my_access_key" \ + --env="MINIO_SECRET_KEY_FILE=my_secret_key" \ + minio/minio server /data +``` + ### Retrieving Container ID To use Docker commands on a specific container, you need to know the `Container ID` for that container. To get the `Container ID`, run