Add custom secret names for Docker (#5355)

master
Paul Trunk 7 years ago committed by Nitish Tiwari
parent 7c72d14027
commit bd9cdcf379
  1. 2
      Dockerfile
  2. 2
      Dockerfile.dev
  3. 2
      Dockerfile.release
  4. 14
      dockerscripts/docker-entrypoint.sh
  5. 11
      docs/docker/README.md

@ -6,6 +6,8 @@ ENV GOPATH /go
ENV PATH $PATH:$GOPATH/bin ENV PATH $PATH:$GOPATH/bin
ENV CGO_ENABLED 0 ENV CGO_ENABLED 0
ENV MINIO_UPDATE off ENV MINIO_UPDATE off
ENV MINIO_ACCESS_KEY_FILE=access_key \
MINIO_SECRET_KEY_FILE=secret_key
WORKDIR /go/src/github.com/minio/ WORKDIR /go/src/github.com/minio/

@ -6,6 +6,8 @@ ENV GOPATH /go
ENV PATH $PATH:$GOPATH/bin ENV PATH $PATH:$GOPATH/bin
ENV CGO_ENABLED 0 ENV CGO_ENABLED 0
ENV MINIO_UPDATE off ENV MINIO_UPDATE off
ENV MINIO_ACCESS_KEY_FILE=access_key \
MINIO_SECRET_KEY_FILE=secret_key
WORKDIR /go/src/github.com/minio/ WORKDIR /go/src/github.com/minio/

@ -5,6 +5,8 @@ MAINTAINER Minio Inc <dev@minio.io>
COPY dockerscripts/docker-entrypoint.sh dockerscripts/healthcheck.sh /usr/bin/ COPY dockerscripts/docker-entrypoint.sh dockerscripts/healthcheck.sh /usr/bin/
ENV MINIO_UPDATE off ENV MINIO_UPDATE off
ENV MINIO_ACCESS_KEY_FILE=access_key \
MINIO_SECRET_KEY_FILE=secret_key
RUN \ RUN \
apk add --no-cache ca-certificates && \ apk add --no-cache ca-certificates && \

@ -24,15 +24,15 @@ fi
## Look for docker secrets in default documented location. ## Look for docker secrets in default documented location.
docker_secrets_env() { docker_secrets_env() {
local MINIO_ACCESS_KEY_FILE="/run/secrets/access_key" local ACCESS_KEY_FILE="/run/secrets/$MINIO_ACCESS_KEY_FILE"
local MINIO_SECRET_KEY_FILE="/run/secrets/secret_key" 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 $ACCESS_KEY_FILE -a -f $SECRET_KEY_FILE ]; then
if [ -f $MINIO_ACCESS_KEY_FILE ]; then if [ -f $ACCESS_KEY_FILE ]; then
export MINIO_ACCESS_KEY="$(cat "$MINIO_ACCESS_KEY_FILE")" export MINIO_ACCESS_KEY="$(cat "$ACCESS_KEY_FILE")"
fi fi
if [ -f $MINIO_SECRET_KEY_FILE ]; then if [ -f $SECRET_KEY_FILE ]; then
export MINIO_SECRET_KEY="$(cat "$MINIO_SECRET_KEY_FILE")" export MINIO_SECRET_KEY="$(cat "$SECRET_KEY_FILE")"
fi fi
fi fi
} }

@ -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/) 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 ### 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 To use Docker commands on a specific container, you need to know the `Container ID` for that container. To get the `Container ID`, run

Loading…
Cancel
Save