Public Repository

Last pushed: a year ago
Short Description
ssh-agent用の専用コンテナ
Full Description
  • Dockerfile
FROM alpine:3.2

MAINTAINER Yoshihisa AMAKATA <amakata@flatz.jp>

ENV SOCKET_DIR /root/.ssh
ENV SSH_AUTH_SOCK ${SOCKET_DIR}/socket
RUN apk add --update openssh && rm -rf /var/cache/apk/*
COPY run.sh /run.sh
RUN chmod +x /run.sh
ADD ssh_config /root/.ssh/config
RUN chmod 600 /root/.ssh/config;
VOLUME ${SOCKET_DIR}
CMD "/run.sh"
  • run.sh
#!/bin/sh

/usr/bin/ssh-agent -a ${SSH_AUTH_SOCK} > /dev/null 2>&1
/usr/bin/ssh-add ${SSH_KEYS} >> /ssh/ssh.log 2>&1
/bin/sh -c "while true; do sleep 1; done"
  • ssh_config
Host *
 ForwardAgent yes
 UserKnownHostsFile /dev/null
 StrictHostKeyChecking no
Host github.com
 Compression yes

whilp/ssh-agent を元にしている

docker-composer での使い方例

app:
  ...
  volumes_from:
    - ssh-agent
ssh-agent:
  image: amakata/ssh-agent
  environment:
    SSH_KEYS: "/ssh/id_rsa1 /ssh/id_rsa2"
  volumes:
    - ~/.ssh:/ssh

ホストOS側の「~/.ssh」フォルダの中にid_rsa1とid_rsa2の鍵をおいておくと、appのコンテナ使えるようになる

Docker Pull Command
Owner
amakata

Comments (0)