Failed to launch a container
Hi, I encountered a problem that is failed to launch a captcha-monitor container.
A reason of failing is refused connection by a postgres container.
How can I solved the problem ?
environments:
- Linux: Ubuntu 20.04.2 LTS
- docker-compose: 1.26.2
- docker: 20.10.5
trying process:
- make command is completed successfully
test@ubuntu:~/CAPTCHA-Monitor$ make
docker-compose down --remove-orphans
Stopping captcha-monitor_tor_1 ... done
Stopping captcha-monitor_postgres_1 ... done
Removing captcha-monitor_captchamonitor_1 ... done
Removing captcha-monitor_tor_1 ... done
Removing captcha-monitor_postgres_1 ... done
Removing network captcha-monitor_captchamonitor_network
docker-compose build
postgres uses an image, skipping
tor uses an image, skipping
WARNING: Native build is an experimental feature and could change at any time
Building captchamonitor
[+] Building 2.7s (13/13) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 38B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.9-buster 0.8s
=> [1/8] FROM docker.io/library/python:3.9-buster@sha256:56f1b4dbdebb3b6ec31126e256c0852d18e79909ed1df8b594e562ab31f9e562 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 55.80kB 0.0s
=> CACHED [2/8] COPY requirements.txt /tmp/ 0.0s
=> CACHED [3/8] RUN pip install -r /tmp/requirements.txt 0.0s
=> CACHED [4/8] RUN mkdir -p /src 0.0s
=> [5/8] COPY src/ /src/ 0.1s
=> [6/8] RUN pip install -e /src 1.5s
=> [7/8] COPY tests/ /tests/ 0.1s
=> [8/8] WORKDIR /src 0.1s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:95398a0573621a89ab0c7bb9a476df75516c3226818a2b761e36cfc51455829b 0.0s
=> => naming to docker.io/library/captcha-monitor_captchamonitor 0.0s
Successfully built 95398a0573621a89ab0c7bb9a476df75516c3226818a2b761e36cfc51455829b
docker-compose up -d
WARNING: Native build is an experimental feature and could change at any time
Creating network "captcha-monitor_captchamonitor_network" with driver "bridge"
Creating captcha-monitor_tor_1 ... done
Creating captcha-monitor_postgres_1 ... done
Creating captcha-monitor_captchamonitor_1 ... done
docker-compose run --rm --no-deps --entrypoint="pytest --cov=/src/captchamonitor/ --cov-report term-missing" captchamonitor /tests
============================================================================================================================ test session starts =============================================================================================================================
platform linux -- Python 3.9.2, pytest-6.2.2, py-1.10.0, pluggy-0.13.1
rootdir: /tests, configfile: pytest.ini
plugins: icdiff-0.5, cov-2.11.1
collected 11 items
../tests/unit/test_cm.py . [ 9%]
../tests/unit/test_config.py .......... [100%]
----------- coverage: platform linux, python 3.9.2-final-0 -----------
Name Stmts Miss Cover Missing
------------------------------------------------------------------
captchamonitor/__init__.py 0 0 100%
captchamonitor/__main__.py 14 14 0% 1-24
captchamonitor/cm.py 23 6 74% 25, 39, 45, 52, 58, 64
captchamonitor/utils/__init__.py 0 0 100%
captchamonitor/utils/config.py 30 0 100%
captchamonitor/utils/database.py 21 13 38% 31-54
captchamonitor/utils/exceptions.py 3 0 100%
captchamonitor/utils/models.py 76 0 100%
------------------------------------------------------------------
TOTAL 167 33 80%
============================================================================================================================= 11 passed in 0.47s =============================================================================================================================
black --line-length 88 $(find * -name '*.py')
All done! ✨ 🍰 ✨
12 files left unchanged.
pylint -v --disable=C0301,R0903,R0913,C0114 --docstring-min-length=10 $(find * -name '*.py' -not -path "tests/*")
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
-
captcha-monitor
container is failed to launch.- it is refused connection by
postgres
container
- it is refused connection by
test@ubuntu:~/CAPTCHA-Monitor$ docker ps -a --no-trunc
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9e98f8ac7a6eb0e701ef9fa1c05e65c4cf91e2f37889eef2e5a87229fb0e5f28 captcha-monitor_captchamonitor "python -m captchamonitor" 17 seconds ago Exited (1) 15 seconds ago captcha-monitor_captchamonitor_1
7f0469ad697834bd9432dc5e7b194fad2cf0de89d3a1a43317cfd29b69273495 osminogin/tor-simple:latest "tor" 18 seconds ago Up 16 seconds (health: starting) 9050/tcp captcha-monitor_tor_1
b4b65440f8bcb0c8cd982a7d9d9728f687e92db3587180730d8249eeda92d13a postgres:9.6 "docker-entrypoint.sh postgres" 18 seconds ago Up 16 seconds 0.0.0.0:5432->5432/tcp captcha-monitor_postgres_1
test@ubuntu:~/CAPTCHA-Monitor$ docker logs 9e98f8ac7a6eb0e701ef9fa1c05e65c4cf91e2f37889eef2e5a87229fb0e5f28
2021-04-01 16:15:39,935 __main__ [INFO] Intializing CAPTCHA Monitor
2021-04-01 16:15:39,946 database [WARNING] Could not connect to the database:
(psycopg2.OperationalError) could not connect to server: Connection refused
Is the server running on host "postgres" (172.26.0.2) and accepting
TCP/IP connections on port 5432?
(Background on this error at: http://sqlalche.me/e/13/e3q8)
2021-04-01 16:15:39,946 cm [WARNING] Could not initialize CAPTCHA Monitor, exitting