docker image prune
docker volume prune
Remove unused images until
docker image prune -a --filter "until=2020-01-02T15:04:05"
Forward ssh agent into a container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
docker run --volume $SSH_AUTH_SOCK:/ssh-agent --env SSH_AUTH_SOCK=/ssh-agent ubuntu ssh-add -l
docker run -i -t -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent \
-e SSH_AUTH_SOCK=/ssh-agent ubuntu /bin/bash
Pass ssh key during building image
# cfg/ssh/config
Host *
StrictHostKeyChecking no
# Docerfile
USER root
WORKDIR /root
COPY cfg/ssh/config .ssh/
RUN chmod -R 700 .ssh
ARG SSH_KEY="NO Key"
RUN set -xe && \
echo "$SSH_KEY" > .ssh/id_rsa && \
chmod -R 700 .ssh && \
eval $(ssh-agent) && \
ssh-add && \
do-something-requiring-ssh-key && \
rm .ssh/id_rsa
docker build --build-arg SSH_KEY=" $( cat ~ /.ssh/id_rsa) " -t my-image:latest .
docker ps -a --format "{{.ID}} : {{.Labels}} : {{.Names}}"
How to access docker volume data from host machine ?
docker volume create --driver local -o o=bind -o type=none -o device=$(pwd)/node-ipc node-ipc