Выполнение сценария Python (называемого localserver.py) на Raspberry Pi работает отлично, однако выполнение этого кода в контейнере Docker приводит к следующей проблеме:
smartmeter_1 | Traceback (most recent call last):
smartmeter_1 | File "/usr/lib/python3.5/asyncio/base_eve
smartmeter_1 | yield from self.sock_connect(sock, addr
smartmeter_1 | File "/usr/lib/python3.5/asyncio/selector
smartmeter_1 | return (yield from fut)
smartmeter_1 | File "/usr/lib/python3.5/asyncio/futures.
smartmeter_1 | yield self # This tells Task to wait f
smartmeter_1 | File "/usr/lib/python3.5/asyncio/tasks.py
smartmeter_1 | future.result()
smartmeter_1 | File "/usr/lib/python3.5/asyncio/futures.
smartmeter_1 | raise self._exception
smartmeter_1 | File "/usr/lib/python3.5/asyncio/selector
smartmeter_1 | raise OSError(err, 'Connect call failed
smartmeter_1 | ConnectionRefusedError: [Errno 111] Connect
smartmeter_1 |
smartmeter_1 | During handling of the above exception, ano
smartmeter_1 |
smartmeter_1 | Traceback (most recent call last):
smartmeter_1 | File "localserver.py", line 223, in <modu
smartmeter_1 | asyncio.get_event_loop().run_until_comp
smartmeter_1 | File "/usr/lib/python3.5/asyncio/base_eve
smartmeter_1 | return future.result()
smartmeter_1 | File "/usr/lib/python3.5/asyncio/futures.
smartmeter_1 | raise self._exception
smartmeter_1 | File "/usr/lib/python3.5/asyncio/tasks.py
smartmeter_1 | result = coro.throw(exc)
smartmeter_1 | File "localserver.py", line 50, in procRe
smartmeter_1 | 'ws://localhost:37379') as websocket:
smartmeter_1 | File "/usr/local/lib/python3.5/dist-packa
smartmeter_1 | return await self
smartmeter_1 | File "/usr/local/lib/python3.5/dist-packa
smartmeter_1 | transport, protocol = await self._creat
smartmeter_1 | File "/usr/lib/python3.5/asyncio/base_eve
smartmeter_1 | ', '.join(str(exc) for exc in exception
smartmeter_1 | OSError: Multiple exceptions: [Errno 111] C Connect call failed ('127.0.0.1', 37379), [Errno 99] Cannot assign requested address
Может быть, отсутствует какая-либо конфигурация?Я довольно новичок в докере, проверил несколько примеров и существующий код.Не совсем уверен, что конфигурация порта выполнена правильно.Заранее спасибо.
localserver.py -------->
async def procReadings():
#await asyncio.sleep(30)
async with websockets.connect(
'ws://localhost:37379') as websocket:
.....
.....
while True:
print(secondsDelay)
#time.sleep(secondsDelay)
time.sleep(5)
asyncio.get_event_loop().run_until_complete(procReadings())
docker-compose.yml ------------------------>
version: '3.3'
services:
# Smartmeter
smartmeter:
build: ./docker
ports:
- 3000:3000
- 8501:8501
- 8546:8546
- 37379:37379
command: sleep infinity
environment:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING=true
- METERID=1
entrypoint: /etc/demo/entrypoint.sh
volumes:
- ./:/etc/demo