Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +71 -17
Dockerfile
CHANGED
|
@@ -1,24 +1,78 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
RUN
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
EXPOSE 80
|
|
|
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
CMD ["
|
|
|
|
| 1 |
+
# Filename: Dockerfile
|
| 2 |
+
# Version: $(date +%s)
|
| 3 |
|
| 4 |
+
# Utiliza Alpine como imagen base
|
| 5 |
+
FROM alpine:latest
|
| 6 |
|
| 7 |
+
# Instalar dependencias necesarias
|
| 8 |
+
RUN apk add --no-cache \
|
| 9 |
+
docker \
|
| 10 |
+
docker-cli \
|
| 11 |
+
shadow \
|
| 12 |
+
sudo \
|
| 13 |
+
curl \
|
| 14 |
+
iptables \
|
| 15 |
+
nginx \
|
| 16 |
+
fuse-overlayfs
|
| 17 |
|
| 18 |
+
# Crear un usuario no root
|
| 19 |
+
RUN adduser -D dockeruser && echo "dockeruser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
| 20 |
|
| 21 |
+
# Cambiar al usuario no root
|
| 22 |
+
USER dockeruser
|
| 23 |
|
| 24 |
+
# Instalar Docker rootless
|
| 25 |
+
RUN curl -fsSL https://get.docker.com/rootless | sh
|
| 26 |
+
|
| 27 |
+
# Configurar Docker rootless
|
| 28 |
+
RUN echo 'export PATH=$HOME/bin:$PATH' >> /home/dockeruser/.bashrc
|
| 29 |
+
RUN echo 'export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock' >> /home/dockeruser/.bashrc
|
| 30 |
+
RUN mkdir -p /home/dockeruser/.config/systemd/user/
|
| 31 |
+
|
| 32 |
+
# Crear el archivo de servicio para Docker rootless
|
| 33 |
+
RUN echo '[Unit]\n\
|
| 34 |
+
Description=Docker Application Container Engine (Rootless)\n\
|
| 35 |
+
Documentation=https://docs.docker.com/go/rootless/\n\
|
| 36 |
+
Wants=network-online.target\n\
|
| 37 |
+
After=network-online.target firewalld.service containerd.service\n\
|
| 38 |
+
StartLimitIntervalSec=0\n\
|
| 39 |
+
\n\
|
| 40 |
+
[Service]\n\
|
| 41 |
+
Environment="PATH=/usr/bin:/usr/sbin"\n\
|
| 42 |
+
ExecStart=/home/dockeruser/bin/dockerd-rootless.sh --experimental --host=tcp://0.0.0.0:7680\n\
|
| 43 |
+
Restart=always\n\
|
| 44 |
+
User=dockeruser\n\
|
| 45 |
+
LimitNOFILE=infinity\n\
|
| 46 |
+
LimitNPROC=infinity\n\
|
| 47 |
+
LimitCORE=infinity\n\
|
| 48 |
+
Delegate=yes\n\
|
| 49 |
+
KillMode=process\n\
|
| 50 |
+
\n\
|
| 51 |
+
[Install]\n\
|
| 52 |
+
WantedBy=default.target' > /home/dockeruser/.config/systemd/user/docker.service
|
| 53 |
+
|
| 54 |
+
# Cambiar al usuario root para configurar Nginx
|
| 55 |
+
USER root
|
| 56 |
+
|
| 57 |
+
# Configurar Nginx
|
| 58 |
+
RUN echo 'server {\n\
|
| 59 |
+
listen 80;\n\
|
| 60 |
+
location /docker {\n\
|
| 61 |
+
proxy_pass http://localhost:7680;\n\
|
| 62 |
+
proxy_set_header Host $host;\n\
|
| 63 |
+
proxy_set_header X-Real-IP $remote_addr;\n\
|
| 64 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\
|
| 65 |
+
proxy_set_header X-Forwarded-Proto $scheme;\n\
|
| 66 |
+
}\n\
|
| 67 |
+
location / {\n\
|
| 68 |
+
return 200 "Hello World";\n\
|
| 69 |
+
add_header Content-Type text/plain;\n\
|
| 70 |
+
}\n\
|
| 71 |
+
}' > /etc/nginx/conf.d/default.conf
|
| 72 |
+
|
| 73 |
+
# Exponer el puerto para la API de Docker y Nginx
|
| 74 |
EXPOSE 80
|
| 75 |
+
EXPOSE 7680
|
| 76 |
|
| 77 |
+
# Configurar el comando de inicio
|
| 78 |
+
CMD ["sh", "-c", "dockerd-rootless.sh --experimental --host=tcp://0.0.0.0:7680 & nginx -g 'daemon off;'"]
|