memex-in commited on
Commit
85fa6c0
·
verified ·
1 Parent(s): a57ffa2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -11
Dockerfile CHANGED
@@ -11,7 +11,6 @@ COPY exdocker ./
11
  # Switch to root user to install curl, as apk requires root privileges
12
  USER root
13
  RUN apk add --no-cache curl
14
-
15
  # Switch back to the default non-root user for dind-rootless (usually 'docker')
16
  # This is important for security and proper operation of the rootless daemon
17
  USER docker
@@ -21,18 +20,35 @@ USER docker
21
  # within the DinD container. Then, we can map this 8080 to the host.
22
  EXPOSE 8080
23
 
24
- # Define the entrypoint to start the rootless Docker daemon
25
- ENTRYPOINT ["/usr/local/bin/dockerd-rootless.sh"]
26
-
27
- # Define the command to execute once the daemon is up:
28
- # 1. Wait for the Docker daemon to be ready (sleep 5 seconds).
29
- # 2. Build the Nginx image using the copied Dockerfile (exdocker).
30
- # 3. Run the Nginx container in detached mode, mapping its port 80
31
- # to port 8080 *inside this DinD container*.
32
- # 4. Keep this DinD container running indefinitely.
33
- CMD ["sh", "-c", "sleep 5 && \
 
 
 
 
 
 
 
 
 
34
  docker build -f exdocker -t my-nginx-app . && \
 
 
 
35
  docker run -d -p 8080:80 --name my-inner-nginx my-nginx-app && \
 
36
  echo 'Inner Nginx container started. Testing accessibility...' && \
 
 
37
  curl http://localhost:8080 && \
 
 
38
  sleep infinity"]
 
11
  # Switch to root user to install curl, as apk requires root privileges
12
  USER root
13
  RUN apk add --no-cache curl
 
14
  # Switch back to the default non-root user for dind-rootless (usually 'docker')
15
  # This is important for security and proper operation of the rootless daemon
16
  USER docker
 
20
  # within the DinD container. Then, we can map this 8080 to the host.
21
  EXPOSE 8080
22
 
23
+ # The base image's ENTRYPOINT is `dockerd-rootless.sh`.
24
+ # We override the default CMD to run our script.
25
+ # Our script will:
26
+ # 1. Start the rootless daemon in the background.
27
+ # 2. Wait for the daemon to be ready.
28
+ # 3. Perform the build and run of the inner Nginx container.
29
+ # 4. Keep the outer container alive.
30
+ CMD ["sh", "-c", "\
31
+ # Start the rootless Docker daemon in the background
32
+ /usr/local/bin/dockerd-rootless.sh & \
33
+ # Wait for the Docker daemon to be fully ready
34
+ # This loop is more robust than a fixed sleep
35
+ until docker info >/dev/null 2>&1; do \
36
+ echo 'Waiting for Docker daemon to start...'; \
37
+ sleep 1; \
38
+ done; \
39
+ echo 'Docker daemon is up and running!'; \
40
+ \
41
+ # Build the Nginx image using the copied exdocker Dockerfile
42
  docker build -f exdocker -t my-nginx-app . && \
43
+ \
44
+ # Run the Nginx container in detached mode, mapping its port 80
45
+ # to port 8080 *inside this DinD container*.
46
  docker run -d -p 8080:80 --name my-inner-nginx my-nginx-app && \
47
+ \
48
  echo 'Inner Nginx container started. Testing accessibility...' && \
49
+ \
50
+ # Test accessibility of the inner Nginx server
51
  curl http://localhost:8080 && \
52
+ \
53
+ # Keep this DinD container running indefinitely
54
  sleep infinity"]