github动作 - 将烧瓶申请推向码头轮毂
祝福,
我制作了一个烧瓶API应用程序,每当我尝试通过GitHub Action将其推到Docker Hub存储库时,它也会失败,当我尝试使用Docker build/运行构建构建完成时,请说此站点无法到达
。
在本地运行烧瓶应用程序时(运行Python文件)时。
Dockerfile
FROM ubuntu
WORKDIR ./app
COPY . /app
RUN apt-get update && apt-get install -y python3 python3-pip firefox
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
EXPOSE 8777
CMD ["python3", "./simpleflask.py", "./main.py"]
我在GitHub上收到以下错误:
Run docker build -t app .
Sending build context to Docker daemon 76.29kB
Step 1/8 : FROM python:3.8
3.8: Pulling from library/python
e756f3fdd6a3: Already exists
bf168a674899: Already exists
e604223835cc: Already exists
6d5c91c4cd86: Already exists
2cc8d8854262: Already exists
2767dbfeeb87: Pulling fs layer
e5a387f746e4: Pulling fs layer
54b770283d3a: Pulling fs layer
d829066ff47d: Pulling fs layer
d829066ff47d: Waiting
54b770283d3a: Verifying Checksum
54b770283d3a: Download complete
2767dbfeeb87: Verifying Checksum
2767dbfeeb87: Download complete
e5a387f746e4: Verifying Checksum
e5a387f746e4: Download complete
d829066ff47d: Verifying Checksum
d829066ff47d: Download complete
2767dbfeeb87: Pull complete
e5a387f746e4: Pull complete
54b770283d3a: Pull complete
d829066ff47d: Pull complete
Digest: sha256:1fbd81716d6d8d6081b11b058894533e36c93abd10d91560ac8011a27ca13947
Status: Downloaded newer image for python:3.8
---> 050b8443e26e
Step 2/8 : WORKDIR ./app
---> Running in 6b66a93bccbb
Removing intermediate container 6b66a93bccbb
---> 784f3185eb08
Step 3/8 : COPY . /app
---> f1ba4f56f664
Step 4/8 : COPY requirements.txt requirements.txt
---> 38014455957c
Step 5/8 : RUN pip install --upgrade pip
---> Running in c635f7bc6af6
Requirement already satisfied: pip in /usr/local/lib/python3.8/site-packages (22.0.4)
Collecting pip
Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 50.0 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-22.1.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Removing intermediate container c635f7bc6af6
---> eac8515be6c0
Step 6/8 : RUN pip install -r requirements.txt
---> Running in 00790d0d61fb
Collecting Flask
Downloading Flask-2.1.2-py3-none-any.whl (95 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 95.2/95.2 kB 16.6 MB/s eta 0:00:00
Collecting Flask-RESTful
Downloading Flask_RESTful-0.3.9-py2.py3-none-any.whl (25 kB)
Collecting itsdangerous>=2.0
Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting Jinja2>=3.0
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 23.7 MB/s eta 0:00:00
Collecting importlib-metadata>=3.6.0
Downloading importlib_metadata-4.11.4-py3-none-any.whl (18 kB)
Collecting Werkzeug>=2.0
Downloading Werkzeug-2.1.2-py3-none-any.whl (224 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.9/224.9 kB 40.4 MB/s eta 0:00:00
Collecting click>=8.0
Downloading click-8.1.3-py3-none-any.whl (96 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 kB 19.9 MB/s eta 0:00:00
Collecting aniso8601>=0.82
Downloading aniso8601-9.0.1-py2.py3-none-any.whl (52 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.8/52.8 kB 12.0 MB/s eta 0:00:00
Collecting six>=1.3.0
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pytz
Downloading pytz-2022.1-py2.py3-none-any.whl (503 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 503.5/503.5 kB 47.0 MB/s eta 0:00:00
Collecting zipp>=0.5
Downloading zipp-3.8.0-py3-none-any.whl (5.4 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Installing collected packages: pytz, aniso8601, zipp, Werkzeug, six, MarkupSafe, itsdangerous, click, Jinja2, importlib-metadata, Flask, Flask-RESTful
Successfully installed Flask-2.1.2 Flask-RESTful-0.3.9 Jinja2-3.1.2 MarkupSafe-2.1.1 Werkzeug-2.1.2 aniso8601-9.0.1 click-8.1.3 importlib-metadata-4.11.4 itsdangerous-2.1.2 pytz-2022.1 six-1.16.0 zipp-3.8.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Removing intermediate container 00790d0d61fb
---> 4d7bca1a1903
Step 7/8 : EXPOSE 5000
---> Running in 5d1710cfff1f
Removing intermediate container 5d1710cfff1f
---> 2d116ca965c0
Step 8/8 : CMD ["python", "./simpleflask.py", "./main.py"]
---> Running in bebab646ec94
Removing intermediate container bebab646ec94
---> 881954660c46
Successfully built 881954660c46
Successfully tagged app:latest
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.8/http/client.py", line 1256, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
self.send(msg)
File "/usr/lib/python3.8/http/client.py", line 951, in send
self.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 187, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f0a6dc8e610>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0a6dc8e610>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./main.py", line 7, in <module>
data = requests.post(url, json=(myobj, mysecobj))
File "/usr/lib/python3/dist-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0a6dc8e610>: Failed to establish a new connection: [Errno 111] Connection refused'))
Error: Process completed with exit code 1.
我也希望可以在此处发布外部链接,但这是存储库 https://github.com/awakzdev/dockerized-api/
main.yml
name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Script
run: |
docker build -t app .
python ./main.py
echo ${{ secrets.DOCKER.SECRET }} | docker login -u ${{ secrets.DOCKER.USERNAME }} --password-stdin
docker tag app awakz/
docker push awakz/dockerized-flask
Blessings,
I made a Flask API application and whenever I try to push it to docker hub repository via GitHub Action it fails, Also when I try to run it using docker build/run the build finishes but says This site can’t be reached
.
While when running the flask application locally (running python file) works.
Dockerfile
FROM ubuntu
WORKDIR ./app
COPY . /app
RUN apt-get update && apt-get install -y python3 python3-pip firefox
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
EXPOSE 8777
CMD ["python3", "./simpleflask.py", "./main.py"]
I get the following error on Github :
Run docker build -t app .
Sending build context to Docker daemon 76.29kB
Step 1/8 : FROM python:3.8
3.8: Pulling from library/python
e756f3fdd6a3: Already exists
bf168a674899: Already exists
e604223835cc: Already exists
6d5c91c4cd86: Already exists
2cc8d8854262: Already exists
2767dbfeeb87: Pulling fs layer
e5a387f746e4: Pulling fs layer
54b770283d3a: Pulling fs layer
d829066ff47d: Pulling fs layer
d829066ff47d: Waiting
54b770283d3a: Verifying Checksum
54b770283d3a: Download complete
2767dbfeeb87: Verifying Checksum
2767dbfeeb87: Download complete
e5a387f746e4: Verifying Checksum
e5a387f746e4: Download complete
d829066ff47d: Verifying Checksum
d829066ff47d: Download complete
2767dbfeeb87: Pull complete
e5a387f746e4: Pull complete
54b770283d3a: Pull complete
d829066ff47d: Pull complete
Digest: sha256:1fbd81716d6d8d6081b11b058894533e36c93abd10d91560ac8011a27ca13947
Status: Downloaded newer image for python:3.8
---> 050b8443e26e
Step 2/8 : WORKDIR ./app
---> Running in 6b66a93bccbb
Removing intermediate container 6b66a93bccbb
---> 784f3185eb08
Step 3/8 : COPY . /app
---> f1ba4f56f664
Step 4/8 : COPY requirements.txt requirements.txt
---> 38014455957c
Step 5/8 : RUN pip install --upgrade pip
---> Running in c635f7bc6af6
Requirement already satisfied: pip in /usr/local/lib/python3.8/site-packages (22.0.4)
Collecting pip
Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 50.0 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-22.1.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Removing intermediate container c635f7bc6af6
---> eac8515be6c0
Step 6/8 : RUN pip install -r requirements.txt
---> Running in 00790d0d61fb
Collecting Flask
Downloading Flask-2.1.2-py3-none-any.whl (95 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 95.2/95.2 kB 16.6 MB/s eta 0:00:00
Collecting Flask-RESTful
Downloading Flask_RESTful-0.3.9-py2.py3-none-any.whl (25 kB)
Collecting itsdangerous>=2.0
Downloading itsdangerous-2.1.2-py3-none-any.whl (15 kB)
Collecting Jinja2>=3.0
Downloading Jinja2-3.1.2-py3-none-any.whl (133 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.1/133.1 kB 23.7 MB/s eta 0:00:00
Collecting importlib-metadata>=3.6.0
Downloading importlib_metadata-4.11.4-py3-none-any.whl (18 kB)
Collecting Werkzeug>=2.0
Downloading Werkzeug-2.1.2-py3-none-any.whl (224 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 224.9/224.9 kB 40.4 MB/s eta 0:00:00
Collecting click>=8.0
Downloading click-8.1.3-py3-none-any.whl (96 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.6/96.6 kB 19.9 MB/s eta 0:00:00
Collecting aniso8601>=0.82
Downloading aniso8601-9.0.1-py2.py3-none-any.whl (52 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 52.8/52.8 kB 12.0 MB/s eta 0:00:00
Collecting six>=1.3.0
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting pytz
Downloading pytz-2022.1-py2.py3-none-any.whl (503 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 503.5/503.5 kB 47.0 MB/s eta 0:00:00
Collecting zipp>=0.5
Downloading zipp-3.8.0-py3-none-any.whl (5.4 kB)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Installing collected packages: pytz, aniso8601, zipp, Werkzeug, six, MarkupSafe, itsdangerous, click, Jinja2, importlib-metadata, Flask, Flask-RESTful
Successfully installed Flask-2.1.2 Flask-RESTful-0.3.9 Jinja2-3.1.2 MarkupSafe-2.1.1 Werkzeug-2.1.2 aniso8601-9.0.1 click-8.1.3 importlib-metadata-4.11.4 itsdangerous-2.1.2 pytz-2022.1 six-1.16.0 zipp-3.8.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Removing intermediate container 00790d0d61fb
---> 4d7bca1a1903
Step 7/8 : EXPOSE 5000
---> Running in 5d1710cfff1f
Removing intermediate container 5d1710cfff1f
---> 2d116ca965c0
Step 8/8 : CMD ["python", "./simpleflask.py", "./main.py"]
---> Running in bebab646ec94
Removing intermediate container bebab646ec94
---> 881954660c46
Successfully built 881954660c46
Successfully tagged app:latest
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 159, in _new_conn
conn = connection.create_connection(
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/usr/lib/python3/dist-packages/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.8/http/client.py", line 1256, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
self.send(msg)
File "/usr/lib/python3.8/http/client.py", line 951, in send
self.connect()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 187, in connect
conn = self._new_conn()
File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 171, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f0a6dc8e610>: Failed to establish a new connection: [Errno 111] Connection refused
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0a6dc8e610>: Failed to establish a new connection: [Errno 111] Connection refused'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./main.py", line 7, in <module>
data = requests.post(url, json=(myobj, mysecobj))
File "/usr/lib/python3/dist-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f0a6dc8e610>: Failed to establish a new connection: [Errno 111] Connection refused'))
Error: Process completed with exit code 1.
I also hope its okay to post external links here but here's the repositoryhttps://github.com/awakzdev/Dockerized-API/
main.yml
name: CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Script
run: |
docker build -t app .
python ./main.py
echo ${{ secrets.DOCKER.SECRET }} | docker login -u ${{ secrets.DOCKER.USERNAME }} --password-stdin
docker tag app awakz/
docker push awakz/dockerized-flask
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论