无法在docker

时间:2017-11-10 08:10:35

标签: python docker flask docker-compose

尝试制作图片时,我收到以下错误。我还要添加相关的项目文件。

  • Dockerfile
  • 搬运工-compose.yml
  • 初始化的.py
  • manage.py

错误:

Building users-service
Step 1/7 : FROM python:3.6.1
ERROR: Service 'users-service' failed to build: Get https://registry-1.docker.io/v2/: dial tcp 52.206.156.207:443: getsockopt: connection refused

这是我的Dockerfile

FROM python:3.6.1

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

ADD ./requirements.txt /usr/src/app/requirements.txt

RUN pip install -r requirements.txt

ADD . /usr/src/app

CMD python manage.py runserver -h 0.0.0.0

这是docker-compose.yml

version: '2.1'

services:

  users-service:
    container_name: users-service
    build: .
    volumes:
      - '.:/usr/src/app'
    ports:
      - 5001:5000 # expose ports - HOST:CONTAINER

初始化的.py

from flask import Flask, jsonify

# instantiate the app
app = Flask(__name__)

# set config
app.config.from_object('project.config.DevelopmentConfig')


@app.route('/ping', methods=['GET'])
def ping_pong():
    return jsonify({'status': 'success',
                    'message': "pong"})

manage.py

from flask_script import Manager

from project import app

# configure your app
manager = Manager(app)

if __name__ == '__main__':
    manager.run()

0 个答案:

没有答案