Since it is troublesome to authenticate every time a new container is created, try sharing the authentication information using volume mount. I made a volume for each user.
I want to create a container for each project, but since both authentication information and default settings are stored under .config / gcloud, if I volume mount and share it, even the default project etc. will be shared between containers.
https://github.com/kihi1215/gcloud-compose
I'm trying various things to share user information and separate project information, and I've written down the details in the README on github.
docker-compose.yml
version: '3'
services:
c1:
build: .
tty: true
volumes:
- config-a:/root/.config/gcloud
c2:
build: .
tty: true
volumes:
- config-b:/root/.config/gcloud
environment:
- CLOUDSDK_ACTIVE_CONFIG_NAME=default
c3:
build: .
tty: true
volumes:
- config-b:/root/.config/gcloud
environment:
- CLOUDSDK_ACTIVE_CONFIG_NAME=www
volumes:
config-a:
config-b:
When using config-b in containers c2 and c3, use CLOUDSDK_ACTIVE_CONFIG_NAME
properly
(Don't worry about building every time)
Dockerfile
FROM kihi1215/gcloud
LABEL maintainer="kihi"
RUN mv /root/.config/gcloud /root/.config/gcloud-old
CMD ["/bin/bash"]
kihi1215/gcloud Dockerfile
FROM centos:8
LABEL maintainer="kihi"
COPY google-cloud-sdk.repo /etc/yum.repos.d/
RUN dnf -y update && \
dnf -y install git && \
dnf -y install google-cloud-sdk && \
dnf clean all
WORKDIR /root
CMD ["/bin/bash"]
The .repo file is a copy of Official This.
I thought it would be easier to grow individual containers instead of sharing with volume mounts. As I noted in the README on github, if I change the directory setting in the user config and mount it there, it seems that malfunctions due to simple and unexpected sharing will be reduced. ..