Skip to content

Instantly share code, notes, and snippets.

@Nek-
Last active January 30, 2019 10:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nek-/fe3b28880254f00d2fc8c99c7338f39e to your computer and use it in GitHub Desktop.
Save Nek-/fe3b28880254f00d2fc8c99c7338f39e to your computer and use it in GitHub Desktop.
Docker in docker
FROM docker:dind
RUN apk update && apk add --no-cache py-pip && apk add --no-cache bash
RUN pip install docker-compose
COPY . /project
WORKDIR /project
COPY docker/scaan/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT /entrypoint.sh
#!/bin/sh
set -e
# no arguments passed
# or first arg is `-f` or `--some-option`
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
# add our default arguments
set -- dockerd \
--host=unix:///var/run/docker.sock \
--host=tcp://0.0.0.0:2375 \
"$@"
fi
if [ "$1" = 'dockerd' ]; then
# if we're running Docker, let's pipe through dind
set -- "$(which dind)" "$@"
# explicitly remove Docker's default PID file to ensure that it can start properly if it was stopped uncleanly (and thus didn't clean up the PID file)
find /run /var/run -iname 'docker*.pid' -delete
fi
exec "$@" &
exec docker-compose up
docker build -t my-dind:latest -f docker/dind/Dockerfile .
docker run --privileged --name my-docker-dind -p 8888:8000 -d my-dind:latest
docker ps | grep my-docker-dind
docker logs my-docker-dind
docker exec --privileged -it my-docker-dind bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment