我有以下 docker-compose.yml
version: '2.1'
services:
files:
image: busybox
volumes:
- ./file/input:/file/input
- ./file/output:/file/output
[..]
classificatore:
build: classificatore/.
volumes:
- ./classificatore:/src
volumes_from:
- files
ports:
- 8080:5000
command: ["python", "/src/main.py"]
depends_on:
rabbit:
condition: service_healthy
mpeg-pre-encoder:
build: mpeg-pre-encoder/.
volumes:
- ./mpeg-pre-encoder:/src
- ./gabac_encoder:/src/gabac_encoder
volumes_from:
- files
depends_on:
rabbit:
condition: service_healthy
rabbit:
image: rabbitmq
ports:
- 5672:5672
healthcheck:
test: ["CMD", "rabbitmqctl", "cluster_status"]
interval: 5s
timeout: 2s
retries: 20
以及以下目录结构:
classificatore/
Dockerfile
[..]
aggregatore/
Dockerfile
[..]
mpeg-pre-encoder/
Dockerfile
[..]
docker-compose.yml
[..]
mpeg-pre-encoder Dockerfile
FROM python:3
RUN mkdir /src
ADD requirements.txt /src/.
WORKDIR /src
RUN pip install -r requirements.txt
ADD . /src/.
CMD ["python", "main.py"]
当我跑步时 docker-compose up -d --build
并检查运行中的容器
docker ps -a
我明白了
b6d7bac3e9b1 encoder_mpeg-pre-encoder "python main.py" 13 seconds ago Exited (1) 9 seconds ago encoder_mpeg-pre-encoder_1
b1182f765113 encoder_classificatore "python /src/main.py" 32 minutes ago Up 32 minutes 0.0.0.0:8080->5000/tcp encoder_classificatore_1
e9d8387430f2 encoder_aggregatore "python /src/main.py" 32 minutes ago Up 32 minutes 0.0.0.0:8000->8000/tcp encoder_aggregatore_1
a69183f42ab6 grafana/grafana:5.1.0 "/run.sh" About an hour ago Up About an hour 0.0.0.0:3000->3000/tcp encoder_grafana_1
ade83e898a98 prom/prometheus "/bin/prometheus --c…" About an hour ago Up 33 minutes 0.0.0.0:9090->9090/tcp encoder_prometheus_1
ff9960a7e924 busybox "sh" About an hour ago Exited (0) 12 seconds ago encoder_files_1
1738eea0645d rabbitmq "docker-entrypoint.s…" 2 weeks ago Up 2 hours (healthy) 4369/tcp, 5671/tcp, 25672/tcp, 0.0.0.0:5672->5672/tcp encoder_rabbit_1
(
encoder_mpeg-pre-encoder容器在构建过程中失败。
关于我为什么会收到此错误的任何提示?
编辑1 :$ docker日志b6d7bac3e9b1
2019-06-10 09:25:58,560 In attesa di nuovi job....
2019-06-10 09:25:58,560 RECEIVED: b"{'file_id': '59f311da-f02f-496a-a899-b1afd1768d64', 'parameter_set': {'reads_len': 136, 'myRnameDict': {'chrM': 0}}, 'au': {'id': 0, 'parameter_set_id': 16, 'au_type': 3, 'sequence_id': 0, 'file_name': '/file/output/minisam/59f311da-f02f-496a-a899-b1afd1768d64/CLASS_M chrM 1:7762.sam', 'AU_start_position': 0, 'AU_end_position': 7897}, 'au_count': 1}"
2019-06-10 09:25:58,561 reading the mini sam file
2019-06-10 09:25:58,582 Tempo totale impiegato per la lettura: 0 sec
2019-06-10 09:25:58,582 Tempo totale impiegato per la lettura: 0 sec
Traceback (most recent call last):
File "main.py", line 68, in <module>
rabbit.wait_for_job(decoded_symbols_from_sam_file)
File "/src/my_util.py", line 55, in wait_for_job
self.channel_input.start_consuming()
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 1822, in start_consuming
self.connection.process_data_events(time_limit=None)
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 758, in process_data_events
self._dispatch_channel_events()
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 521, in _dispatch_channel_events
impl_channel._get_cookie()._dispatch_events()
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 1445, in _dispatch_events
evt.body)
File "/src/my_util.py", line 48, in callback
worker_function(eval(body))
File "<decorator-gen-1>", line 2, in decoded_symbols_from_sam_file
File "/usr/local/lib/python3.7/site-packages/prometheus_client/context_managers.py", line 66, in wrapped
return func(*args, **kwargs)
File "main.py", line 38, in decoded_symbols_from_sam_file
mpegg_fields = convert_sam_to_mpegg(sam_fields, job_data['parameter_set']['myRnameDict'])
File "/src/mpegg_fields.py", line 40, in convert_sam_to_mpegg
mpegg_line[MPEGG_FIELD_ECIGAR_STRING] = calculate_ECIGAR_STRING(sam_line)
File "/src/mpegg_fields.py", line 107, in calculate_ECIGAR_STRING
raise ('Impossible to calculate ecigar string')
TypeError: exceptions must derive from BaseException
编辑2 :在Docker外部运行mpeg-pre-encoder脚本
$python main.py
2019-06-10 12:49:29,541 Address resolution failed: gaierror(-2, 'Name or service not known')
2019-06-10 12:49:29,542 getaddrinfo failed: gaierror(-2, 'Name or service not known').
2019-06-10 12:49:29,542 AMQP connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - gaierror(-2, 'Name or service not known'); first exception - None.
2019-06-10 12:49:29,543 AMQPConnectionWorkflow - reporting failure: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - gaierror(-2, 'Name or service not known'); first exception - None
2019-06-10 12:49:29,543 Connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - gaierror(-2, 'Name or service not known'); first exception - None
2019-06-10 12:49:29,543 Error in _create_connection().
Traceback (most recent call last):
File "/home/martina/PycharmProjects/mpegg_std/venv/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
raise self._reap_last_connection_workflow_error(error)
File "/home/martina/PycharmProjects/mpegg_std/venv/lib/python3.6/site-packages/pika/adapters/utils/selector_ioloop_adapter.py", line 564, in _resolve
self._flags)
File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
Traceback (most recent call last):
File "main.py", line 18, in <module>
rabbit = Rabbit()
File "/home/martina/PycharmProjects/mpegg_std/venv/lib/python3.6/site-packages/singleton_decorator/decorator.py", line 14, in __call__
self._instance = self.__wrapped__(*args, **kwargs)
File "/home/martina/PycharmProjects/mpegg_std/applicazione/encoder/mpeg-pre-encoder/my_util.py", line 26, in __init__
self.initConnect()
File "/home/martina/PycharmProjects/mpegg_std/applicazione/encoder/mpeg-pre-encoder/my_util.py", line 19, in initConnect
self.connection = pika.BlockingConnection(pika.ConnectionParameters(host=RABBIT_HOST))
File "/home/martina/PycharmProjects/mpegg_std/venv/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 360, in __init__
self._impl = self._create_connection(parameters, _impl_class)
File "/home/martina/PycharmProjects/mpegg_std/venv/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 451, in _create_connection
raise self._reap_last_connection_workflow_error(error)
File "/home/martina/PycharmProjects/mpegg_std/venv/lib/python3.6/site-packages/pika/adapters/utils/selector_ioloop_adapter.py", line 564, in _resolve
self._flags)
File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known
编辑3: 我隔离了来自异常的错误,但收到了一个更严重的错误。实际上,当分类服务将数据发送到队列时,将触发mpeg-pre-encoder服务。我认为rabbitMQ中有问题,如何检查我是否正确?
在mpeg-pre-encoder服务构建日志下面:
Building mpeg-pre-encoder
Step 1/7 : FROM python:3
---> a4cc999cf2aa
Step 2/7 : RUN mkdir /src
---> Using cache
---> 31d8a2dc751d
Step 3/7 : ADD requirements.txt /src/.
---> Using cache
---> 9c58880cc0b1
Step 4/7 : WORKDIR /src
---> Using cache
---> 910b4249cc31
Step 5/7 : RUN pip install -r requirements.txt
---> Using cache
---> a8dc0f729257
Step 6/7 : ADD . /src/.
---> Using cache
---> 591968ce0427
Step 7/7 : CMD ["python", "main.py"]
---> Using cache
---> b1500f95a936
Successfully built b1500f95a936
Successfully tagged encoder_mpeg-pre-encoder:latest
似乎运行良好,但是我一运行docker ps -a
9e7c4723cd98 encoder_mpeg-pre-encoder "python main.py" 17 seconds ago Exited (1) 14 seconds ago encoder_mpeg-pre-encoder_1
有其他错误
Traceback (most recent call last):
File "main.py", line 45, in <module>
rabbit.wait_for_job(decoded_symbols_from_sam_file)
File "/src/my_util.py", line 55, in wait_for_job
self.channel_input.start_consuming()
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 1822, in start_consuming
self.connection.process_data_events(time_limit=None)
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 758, in process_data_events
self._dispatch_channel_events()
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 521, in _dispatch_channel_events
impl_channel._get_cookie()._dispatch_events()
File "/usr/local/lib/python3.7/site-packages/pika/adapters/blocking_connection.py", line 1445, in _dispatch_events
evt.body)
File "/src/my_util.py", line 48, in callback
worker_function(eval(body))
File "<decorator-gen-1>", line 2, in decoded_symbols_from_sam_file
File "/usr/local/lib/python3.7/site-packages/prometheus_client/context_managers.py", line 66, in wrapped
return func(*args, **kwargs)
File "main.py", line 26, in decoded_symbols_from_sam_file
COUNTER_INPUT_FILE_SIZE.inc(path.getsize(file_path))
File "/usr/local/lib/python3.7/genericpath.py", line 50, in getsize
return os.stat(filename).st_size
FileNotFoundError: [Errno 2] No such file or directory: '/file/output/minisam/9fdb727a-5093-4800-a1ba-c807dc48ca99/CLASS_P chrM 1:7757.sam'
答案 0 :(得分:1)
您正在尝试使用python 3解释器运行python 2代码。他们更改了版本之间处理异常的方式,所以现在您不能只raise 'My exception'
。
将基本容器更改为python 2或重写代码,python 2即将在2020年寿终正寝。