File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 37
37
python -m pip install --upgrade pip
38
38
pip install wheel
39
39
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
40
50
- name : Run checks
41
51
run : |
42
52
flake8
Original file line number Diff line number Diff line change @@ -4,6 +4,6 @@ FROM python:${version}
4
4
WORKDIR /workspace
5
5
ARG version=3.8
6
6
COPY requirements/${version}.txt requirements.txt
7
- COPY setup.py README.md ./
7
+ COPY setup.py README.rst ./
8
8
RUN pip install -r requirements.txt
9
9
COPY . .
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