Spaces:
Build error
Build error
File size: 2,354 Bytes
9ecdcba cafecb9 9ecdcba cafecb9 9ecdcba 1088f52 cafecb9 9ecdcba 1088f52 cafecb9 9ecdcba cafecb9 1088f52 9ecdcba 1088f52 9ecdcba cafecb9 9ecdcba cafecb9 9ecdcba 1088f52 |
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# Filename: Dockerfile
# Version: $(date +%s)
FROM alpine:latest
# Instalar dependencias necesarias
RUN apk add --no-cache \
docker \
docker-cli \
shadow \
sudo \
curl \
iptables \
nginx \
fuse-overlayfs \
shadow-uidmap
# Crear un usuario no root
RUN adduser -D -g '' dockeruser && echo "dockeruser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Cambiar al usuario no root
USER dockeruser
# Configurar Docker rootless manualmente
RUN curl -fsSL https://download.docker.com/linux/static/stable/x86_64/docker-rootless-extras-20.10.7.tgz | tar -xz -C ~/
RUN ~/docker-rootless-extras/install
RUN echo 'export PATH=$HOME/bin:$PATH' >> /home/dockeruser/.profile
RUN echo 'export DOCKER_HOST=unix:///run/user/1000/docker.sock' >> /home/dockeruser/.profile
# Crear el archivo de servicio para Docker rootless
RUN mkdir -p /home/dockeruser/.config/systemd/user/ && \
echo '[Unit]\n\
Description=Docker Application Container Engine (Rootless)\n\
Documentation=https://docs.docker.com/go/rootless/\n\
Wants=network-online.target\n\
After=network-online.target firewalld.service containerd.service\n\
StartLimitIntervalSec=0\n\
\n\
[Service]\n\
Environment="PATH=/usr/bin:/usr/sbin"\n\
ExecStart=/home/dockeruser/bin/dockerd-rootless.sh --experimental --host=tcp://0.0.0.0:7680\n\
Restart=always\n\
User=dockeruser\n\
LimitNOFILE=infinity\n\
LimitNPROC=infinity\n\
LimitCORE=infinity\n\
Delegate=yes\n\
KillMode=process\n\
\n\
[Install]\n\
WantedBy=default.target' > /home/dockeruser/.config/systemd/user/docker.service
# Cambiar al usuario root para configurar Nginx
USER root
# Configurar Nginx
RUN echo 'server {\n\
listen 80;\n\
location /docker {\n\
proxy_pass http://localhost:7680;\n\
proxy_set_header Host $host;\n\
proxy_set_header X-Real-IP $remote_addr;\n\
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n\
proxy_set_header X-Forwarded-Proto $scheme;\n\
}\n\
location / {\n\
return 200 "Hello World";\n\
add_header Content-Type text/plain;\n\
}\n\
}' > /etc/nginx/conf.d/default.conf
# Exponer el puerto para la API de Docker y Nginx
EXPOSE 80
EXPOSE 7680
# Configurar el comando de inicio
CMD ["sh", "-c", "~/.docker-rootless-extras/docker-rootless.sh --experimental --host=tcp://0.0.0.0:7680 & nginx -g 'daemon off;'"] |