File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 python -m pip install --upgrade pip
3838 pip install wheel
3939 pip install -r requirements/${{ matrix.python-version }}.txt
40+ - name : Run docker diagnostics
41+ run : |
42+ echo "Build minimal container for docker-in-docker diagnostics"
43+ docker build -f Dockerfile.diagnostics -t testcontainers-python .
44+ echo "Bare metal diagnostics"
45+ python diagnostics.py
46+ echo "Container diagnostics with bridge network"
47+ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --network=bridge testcontainers-python python diagnostics.py
48+ echo "Container diagnostics with host network"
49+ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --network=host testcontainers-python python diagnostics.py
4050 - name : Run checks
4151 run : |
4252 flake8
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ FROM python:${version}
44WORKDIR /workspace
55ARG version=3.8
66COPY requirements/${version}.txt requirements.txt
7- COPY setup.py README.md ./
7+ COPY setup.py README.rst ./
88RUN pip install -r requirements.txt
99COPY . .
Original file line number Diff line number Diff line change 1+ ARG version=3.8
2+ FROM python:${version}
3+
4+ WORKDIR /workspace
5+ COPY setup.py README.rst ./
6+ RUN pip install -e .
7+ COPY . .
Original file line number Diff line number Diff line change 1+ import json
2+ from testcontainers .core import utils
3+ from testcontainers .core .container import DockerContainer
4+
5+
6+ result = {
7+ 'is_linux' : utils .is_linux (),
8+ 'is_mac' : utils .is_mac (),
9+ 'is_windows' : utils .is_windows (),
10+ 'inside_container' : utils .inside_container (),
11+ 'default_gateway_ip' : utils .default_gateway_ip (),
12+ }
13+
14+ with DockerContainer ('alpine:latest' ) as container :
15+ client = container .get_docker_client ()
16+ result .update ({
17+ 'container_host_ip' : container .get_container_host_ip (),
18+ 'docker_client_gateway_ip' : client .gateway_ip (container ._container .id ),
19+ 'docker_client_bridge_ip' : client .bridge_ip (container ._container .id ),
20+ 'docker_client_host' : client .host (),
21+ })
22+
23+ print (json .dumps (result , indent = 2 ))
You can’t perform that action at this time.
0 commit comments