【发布时间】:2020-06-14 12:22:52
【问题描述】:
我对容器世界和 docker 非常陌生,但由于我正在从事的项目的特定基础架构限制,我觉得它是我需要利用的技术。
我正在尝试在我的 Windows 10 机器上构建我的应用程序,然后将其迁移到另一台 Windows 10 计算机上,该计算机位于另一个无法访问互联网且没有通信的网络上(我只能从我的主网络)。该应用程序是在 uWsgi/nginx 服务器上运行的 Flask 应用程序。
我遵循了一些关于 docker 和 docker compose 的教程,并提出了以下应用程序结构:
Application
- flask
- app
- env
- Dockerfile
- app.config
- run.py
- nginx
- Dockerfile
- nginx.conf
- docker-compose.yml
docker compose 文件的内容:
version: "3.7"
services:
nginx:
build: ./nginx
image: nginx
container_name: nginx
restart: always
ports:
- "80:80"
- "443:443"
flask:
build: ./flask
container_name: flask
restart: always
image: trac
environment:
- APP_NAME=Trac
expose:
- 8080
depends_on:
- nginx
flask Dockerfile 的内容:
# Use python 3.7 container image
FROM python:3.7.2-stretch
# Set the working directory of the app
WORKDIR /app
# Copy the directory contents into the container at /app
ADD . /app
# Install the dependencies
RUN pip install -r requirements.txt
# run the command to start uWSGI
CMD ["uwsgi", "app.ini"]
app.ini 的内容
[uwsgi]
wsgi-file = run.py
callable = app
socket = :8080
processes = 4
threads = 2
master = true
chmod-socket = 660
vacuum = true
die-on-term = true
nginx Dockerfile 的内容: 来自 nginx
RUN rm /etc/nginx/conf.d/default.conf
COPY crt.crt /etc/nginx/
COPY key.key /etc/nginx/
COPY nginx.conf /etc/nginx/conf.d
nginx.conf 的内容
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl http2 default_server;
ssl_certificate crt.crt;
ssl_certificate_key key.key;
location / {
include uwsgi_params;
uwsgi_pass flask:8080;
}
}
当使用 docker-compose build 时,我构建了多个我认为不会是预期结果的图像?我想我在想这将是一个单一的图像,然后可以移动并在其他地方运行。
但问题是如何移动图像并在没有互联网访问的计算机上运行它们。
我能够在本地构建应用程序并且一切正常。
对此的任何帮助都会很棒。提前致谢。
【问题讨论】:
-
running them on the computer with no internet access.上面安装了 docker 吗? -
是的。我在那台机器上安装了 Docker Desktop for Windows。
标签: docker nginx flask docker-compose uwsgi