Hands-on task
A sidecar in someone else's network namespace
legacy is a contractor's service in the app network: it listens only on 127.0.0.1:8080 inside its container, and that can't be fixed — you may not touch the image or the settings, and the container must not be recreated. Its network neighbors (for example, client) can't reach it.
A proxy config is ready at /root/edge/default.conf: nginx listens on port 8088 and passes requests on to 127.0.0.1:8080. Start a container edge from nginx:1.27-alpine next to it with this config (in place of /etc/nginx/conf.d/default.conf) so that it shares the network namespace of legacy. Then they have a common 127.0.0.1, and client can open http://legacy:8088/.
The lab has its own Docker with no internet access; the images are already loaded: izzylab/minihttp:1, alpine:3.21, busybox:1.36, nginx:1.27-alpine. izzylab/minihttp is a tiny HTTP service on port 8080: GET / answers <NAME> ok, GET /call itself goes to http://<UPSTREAM>/ and answers <NAME> -> <the neighbor's reply> (or 502), GET /env shows its settings. It is configured with the environment variables NAME, PORT, BIND (the address it listens on) and UPSTREAM.
- sidecar
- docker network container
- nginx proxy