-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (34 loc) · 1.44 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (34 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
FROM python:3.12-slim
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
LABEL org.opencontainers.image.source=https://github.com/newdave/docker-hostsfile
LABEL org.opencontainers.image.description="Automatically updates /etc/hosts with Docker container IPs and FQDNs"
LABEL org.opencontainers.image.licenses=MIT
# Install Docker CLI from official Docker repository
# shellcheck disable=SC1091
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg && \
install -m 0755 -d /etc/apt/keyrings && \
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg && \
chmod a+r /etc/apt/keyrings/docker.gpg && \
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null && \
apt-get update && \
apt-get install -y --no-install-recommends docker-ce-cli && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy the updater script
COPY src/docker_hosts_updater.py /app/
# Make script executable
RUN chmod +x /app/docker_hosts_updater.py
# Set Python to unbuffered mode for better logging
ENV PYTHONUNBUFFERED=1
# Default command (can be overridden)
ENTRYPOINT ["python3", "/app/docker_hosts_updater.py"]
CMD ["30s"]