File size: 1,393 Bytes
6d3bb8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/sh

# Start the rootless Docker daemon in the background
# The `docker:dind-rootless` image's ENTRYPOINT is already `dockerd-rootless.sh`.
# We need to ensure it runs as the primary process, and then our commands follow.
# The `dind-rootless` image sets up the environment variables for rootless mode.
# We'll run dockerd directly and wait for it.

echo "Starting dockerd-rootless.sh in the background..."
dockerd-rootless.sh &

# Wait for the Docker daemon to be fully ready
# This loop is more robust than a fixed sleep
until docker info >/dev/null 2>&1; do
    echo 'Waiting for Docker daemon to start...'
    sleep 1
done
echo 'Docker daemon is up and running!'

# Build the Nginx image using the copied exdocker Dockerfile
echo "Building my-nginx-app image..."
docker build -f exdocker -t my-nginx-app .

# Run the Nginx container in detached mode, mapping its port 80
# to port 8080 *inside this DinD container*.
echo "Running my-inner-nginx container..."
docker run -d -p 8080:80 --name my-inner-nginx my-nginx-app

echo 'Inner Nginx container started. Testing accessibility...'

# Test accessibility of the inner Nginx server
curl http://localhost:8080

# Keep this DinD container running indefinitely
echo "DinD container is running. Access Nginx at http://localhost:8080 (from host)."
wait # Wait for background processes (like dockerd) to finish, keeping the container alive