Skip to content

Latest commit

 

History

History
55 lines (52 loc) · 2.37 KB

README.ENVIRONMENT.CLEANUP.md

File metadata and controls

55 lines (52 loc) · 2.37 KB

Univention Corporate Server - Container Mode

This is a self deploying container for running a Univention Corporate Server (UCS) with the role of primary, backup, replica directory node or managed node.

CLI SYNTAX:

KEY=VALUE; ...; \
  COMMAND \
    --<COMMAND OPTION(S)> \
      <COMMAND ARGUMENT(S)>
...
STDOUT ( succeed )
...
STDOUT ( timeing )
...

Clean deployed container image from sensitive credentials from environment

Step 1. Stop and export the container to temporarily image

CONTAINER=sdc.ucs.example; IMAGE=univention-corporate-server; STAGE=export; TAG=latest; \
  docker stop ${CONTAINER} && \
    docker export ${CONTAINER} | \
    docker import - \
      ${IMAGE}:${STAGE}

Step 2. Build new image from temporarlly image

This will also clean the whole Docker in Docker environment! (rm -rfv /var/lib/docker/* /var/lib/containerd/*)

CONTAINER=sdc.ucs.example; IMAGE=univention-corporate-server; STAGE=export; TAG=latest; \
  docker build \
    --build-arg COMMENT="$(docker image inspect --format '{{.Comment}}' univention-corporate-server-debootstrap:latest)" \
    --build-arg CONTAINER=${CONTAINER} \
    --build-arg DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
    --build-arg IMAGE=${IMAGE} \
    --build-arg STAGE=${STAGE} \
    --build-arg TAG=${TAG} \
    --tag ${CONTAINER}:${TAG} \
    --file clean.environment.Dockerfile .

Inspect the new image.

CONTAINER=sdc.ucs.example; TAG=latest; \
  docker image inspect ${CONTAINER}:${TAG} && \
  docker image inspect --format '{{ index .Config.Labels "org.label-schema.docker.cmd"}}' ${CONTAINER}:${TAG}

Step 3. Redeploy the new container

CONTAINER=sdc.ucs.example; TAG=latest; \
  docker rm \
    --force \
    --volumes \
      ${CONTAINER} && \
$(docker image inspect --format '{{ index .Config.Labels "org.label-schema.docker.cmd"}}' ${CONTAINER}:${TAG})