Skip to content

Instantly share code, notes, and snippets.

@ArloL
Created December 21, 2023 20:18
Show Gist options
  • Save ArloL/c22fe35ccc39c27db1434621a7de7a56 to your computer and use it in GitHub Desktop.
Save ArloL/c22fe35ccc39c27db1434621a7de7a56 to your computer and use it in GitHub Desktop.
Dockerfile that installs docker in ubuntu
ARG DOCKER_REGISTRY=registry.hub.docker.com
FROM $DOCKER_REGISTRY/library/ubuntu:22.04 AS base
# install docker
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update \
&& apt-get --yes install \
ca-certificates \
gnupg \
curl \
coreutils \
git \
make \
&& rm -rf /var/lib/apt/lists/*
RUN install -m 0755 -d /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
RUN chmod a+r /etc/apt/keyrings/docker.gpg
RUN echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN \
--mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get update \
&& apt-get --yes install \
docker-ce \
docker-ce-cli \
docker-buildx-plugin \
&& rm -rf /var/lib/apt/lists/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment