Spaces:
Build error
Build error
Create start.sh
Browse files
start.sh
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
|
3 |
+
# Start the rootless Docker daemon in the background
|
4 |
+
# The `docker:dind-rootless` image's ENTRYPOINT is already `dockerd-rootless.sh`.
|
5 |
+
# We need to ensure it runs as the primary process, and then our commands follow.
|
6 |
+
# The `dind-rootless` image sets up the environment variables for rootless mode.
|
7 |
+
# We'll run dockerd directly and wait for it.
|
8 |
+
|
9 |
+
echo "Starting dockerd-rootless.sh in the background..."
|
10 |
+
dockerd-rootless.sh &
|
11 |
+
|
12 |
+
# Wait for the Docker daemon to be fully ready
|
13 |
+
# This loop is more robust than a fixed sleep
|
14 |
+
until docker info >/dev/null 2>&1; do
|
15 |
+
echo 'Waiting for Docker daemon to start...'
|
16 |
+
sleep 1
|
17 |
+
done
|
18 |
+
echo 'Docker daemon is up and running!'
|
19 |
+
|
20 |
+
# Build the Nginx image using the copied exdocker Dockerfile
|
21 |
+
echo "Building my-nginx-app image..."
|
22 |
+
docker build -f exdocker -t my-nginx-app .
|
23 |
+
|
24 |
+
# Run the Nginx container in detached mode, mapping its port 80
|
25 |
+
# to port 8080 *inside this DinD container*.
|
26 |
+
echo "Running my-inner-nginx container..."
|
27 |
+
docker run -d -p 8080:80 --name my-inner-nginx my-nginx-app
|
28 |
+
|
29 |
+
echo 'Inner Nginx container started. Testing accessibility...'
|
30 |
+
|
31 |
+
# Test accessibility of the inner Nginx server
|
32 |
+
curl http://localhost:8080
|
33 |
+
|
34 |
+
# Keep this DinD container running indefinitely
|
35 |
+
echo "DinD container is running. Access Nginx at http://localhost:8080 (from host)."
|
36 |
+
wait # Wait for background processes (like dockerd) to finish, keeping the container alive
|