Last active
May 20, 2021 16:54
-
-
Save diegomengarda/2ad968a499fdbbe599c7fda4e2e94066 to your computer and use it in GitHub Desktop.
docker inside 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
docker build -t ubuntu-docker:latest . | |
docker run -it -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd)/app:/app ubuntu-docker:latest bash |
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 ubuntu:latest | |
LABEL maintainer="Diego Mengarda <[email protected]>" | |
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 | |
ARG ssh_pub_key="" | |
ARG ssh_prv_key="" | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl software-properties-common gpg-agent nano && \ | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \ | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" && \ | |
apt update && \ | |
apt install -y docker-ce docker-compose | |
# Authorize SSH Host | |
RUN mkdir -p /root/.ssh && \ | |
chmod 0700 /root/.ssh && \ | |
ssh-keyscan bitbucket.org > /root/.ssh/known_hosts | |
# Add the keys and set permissions | |
RUN echo "$ssh_prv_key" > /root/.ssh/id_rsa && \ | |
echo "$ssh_pub_key" > /root/.ssh/id_rsa.pub && \ | |
chmod 600 /root/.ssh/id_rsa && \ | |
chmod 600 /root/.ssh/id_rsa.pub | |
COPY id_rsa /root/.ssh/id_rsa | |
COPY id_rsa.pub /root/.ssh/id_rsa.pub | |
COPY start.sh /usr/local/bin/start | |
RUN chmod +x /usr/local/bin/start | |
#ensures that /var/run/docker.sock exists | |
RUN touch /var/run/docker.sock | |
#changes the ownership of /var/run/docker.sock | |
RUN chown root:docker /var/run/docker.sock | |
#gives jenkins user permissions to access /var/run/docker.sock | |
RUN usermod -a -G docker root | |
ENTRYPOINT ["start"] |
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 | |
mkdir -p app/adopter | |
git clone [email protected]:diegomengarda/api-adopter.git app/adopter | |
docker run --rm -it -v $(pwd)/app/adopter:/app composer ls -la | |
exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment