Last active
January 30, 2019 10:41
-
-
Save Nek-/fe3b28880254f00d2fc8c99c7338f39e to your computer and use it in GitHub Desktop.
Docker in docker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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