memex-in commited on
Commit
01a0068
·
verified ·
1 Parent(s): 6d31700

Delete start.sh

Browse files
Files changed (1) hide show
  1. start.sh +0 -73
start.sh DELETED
@@ -1,73 +0,0 @@
1
- #!/bin/bash
2
- set -eo pipefail # Exit immediately if a command exits with a non-zero status.
3
- # Also exit if any command in a pipeline fails.
4
-
5
- # Ensure /usr/local/bin is in PATH for the 'docker' user
6
- export PATH="/usr/local/bin:$PATH"
7
-
8
- echo "--- Debugging Environment ---"
9
- echo "Current user: $(whoami)"
10
- echo "Current working directory: $(pwd)"
11
- echo "PATH: $PATH"
12
- echo "--- File System Checks ---"
13
- echo "Listing contents of /usr/local/bin/"
14
- ls -la /usr/local/bin/ || echo "ls failed in /usr/local/bin"
15
-
16
- echo "Checking for dockerd-rootless.sh using 'which'"
17
- which dockerd-rootless.sh || echo "dockerd-rootless.sh not found by 'which'"
18
-
19
- echo "Checking for dockerd-rootless.sh using 'find' from root"
20
- find / -name "dockerd-rootless.sh" 2>/dev/null || echo "dockerd-rootless.sh not found by 'find'"
21
-
22
- echo "--- Starting Docker Daemon ---"
23
- # Start the rootless Docker daemon in the background.
24
- # The `docker:dind-rootless` image's default `ENTRYPOINT` is `dockerd-rootless.sh`.
25
- # Since we are overriding the ENTRYPOINT with `start.sh`, `start.sh` must explicitly
26
- # run `dockerd-rootless.sh`.
27
- # We use `exec` here so that `dockerd-rootless.sh` becomes the main process,
28
- # allowing it to correctly set up the rootless environment and `rootlesskit` re-execution.
29
- # We then put it in the background and wait for it.
30
-
31
- # IMPORTANT: The `dockerd-rootless.sh` script itself uses `exec rootlesskit ... $0 $@`
32
- # This means it replaces the current shell process.
33
- # So, we cannot simply run it with `&` and expect the rest of `start.sh` to execute.
34
- # Instead, we need to manage the daemon's lifecycle differently.
35
-
36
- # Let's try to run dockerd-rootless.sh directly as the primary process,
37
- # and then use a separate mechanism to run our build/run commands.
38
- # This is problematic for a single CMD/ENTRYPOINT.
39
-
40
- # Alternative approach: Run dockerd-rootless.sh in the background, but use a loop to wait for its socket.
41
- # This is the most common pattern for DinD when you need to run other commands.
42
- echo "Attempting to run dockerd-rootless.sh in background and wait for socket..."
43
- /usr/local/bin/dockerd-rootless.sh &
44
- DAEMON_PID=$! # Capture the PID of the background daemon
45
-
46
- # Wait for the Docker daemon to be fully ready
47
- echo "Waiting for Docker daemon to become available..."
48
- until docker info >/dev/null 2>&1; do
49
- echo 'Still waiting for Docker daemon to start...'
50
- sleep 1
51
- done
52
- echo 'Docker daemon is up and running!'
53
-
54
- echo "--- Performing Inner Docker Operations ---"
55
- # Build the Nginx image using the copied exdocker Dockerfile
56
- echo "Building my-nginx-app image..."
57
- docker build -f exdocker -t my-nginx-app .
58
-
59
- # Run the Nginx container in detached mode, mapping its port 80
60
- # to port 8080 *inside this DinD container*.
61
- echo "Running my-inner-nginx container..."
62
- docker run -d -p 8080:80 --name my-inner-nginx my-nginx-app
63
-
64
- echo 'Inner Nginx container started. Testing accessibility...'
65
-
66
- # Test accessibility of the inner Nginx server
67
- curl http://localhost:8080
68
-
69
- echo "--- DinD Container Running ---"
70
- echo "DinD container is running. Access Nginx at http://localhost:8080 (from host)."
71
-
72
- # Keep this DinD container running indefinitely by waiting on the daemon process
73
- wait $DAEMON_PID # Wait for the dockerd-rootless.sh process to finish, which keeps the container alive