My issue is after the entrypoint file is executed the docker vault container exits. When I do not execute any commands in the entrypoint past vault server initialize and remove the background task call & it doesn't exit. I was told to add tty:true to my docker-compose.yml but thats not helping.
I have the folllowing docker-compose.yml:
services:
vault:
image: vault
build:
context: support/docker/vault
dockerfile: Dockerfile
ports:
- 8200:1234
environment:
- VAULT_DEV_ROOT_TOKEN_ID=myroot
- VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:1234
cap_add:
- IPC_LOCK
tty: true
I have the following Dockerfile:
FROM alpine:3.12
ENV VAULT_VERSION 1.7.1
RUN apk --no-cache add bash ca-certificates dos2unix
RUN mkdir -p /vault/bin
RUN mkdir -p /vault/config
RUN chmod -R 755 /vault
RUN cd /vault/bin
COPY vault /vault/bin
RUN chmod +x /vault/bin/vault
ENV PATH="PATH=$PATH:/vault/bin"
COPY entrypoint.sh /tmp/entrypoint.sh
RUN chmod +x /tmp/entrypoint.sh
RUN dos2unix /tmp/entrypoint.sh
EXPOSE 8200
ENTRYPOINT ["/bin/sh","/tmp/entrypoint.sh"]
And I have the following entrypoint.sh
#!/bin/sh
export VAULT_ADDR='http://0.0.0.0:1234'
export VAULT_TOKEN=myroot
vault server -config=/vault/config -dev-root-token-id=myroot -dev-listen-address=0.0.0.0:1234 -dev &
vault login myroot
vault secrets disable secret
vault secrets enable -version=1 -path=secret -description='local secrets' kv
vault write secret/foo foo=bar
I was told to add tty:true to my docker-compose.yml but the vault container still exits after it executes the entrypoint.sh file, specifically when i execute everything past vault server else it doesn't exit when i remove the & background server flag and remove the commands past the vault server command
ENTRYPOINTmeans; a command you specify this way runs instead of the normal main container command. I'd suggest configuring Vault from a separate container or using a non-container script.