从多个容器创建单个docker映像

问题描述 投票:0回答:2

我对容器世界和Docker还是非常陌生,但是由于我正在从事的项目的特定基础架构限制,我感到需要利用它的技术。

我正在尝试在Windows 10计算机上构建我的应用程序,然后将其迁移到另一台Windows 10计算机上,该计算机位于另一个无法访问Internet且无法进行通信的网络上(我只能从主网络进行推/拉)。该应用程序是在uWsgi / nginx服务器上运行的Flask应用程序。

我遵循了一些有关docker和docker的教程,并提出了以下应用程序结构:

Application
    - flask
        - app
        - env
        - Dockerfile
        - app.config
        - run.py
    - nginx
        - Dockerfile
        - nginx.conf
    - docker-compose.yml

docker撰写文件的内容:

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

烧瓶烧瓶文件的内容:

# 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构建时,我获得了多个镜像,我认为这不是理想的结果?我想我当时想这将是一个图像,然后可以将其移动并在其他位置运行。

但是问题是如何移动图像并在无法访问互联网的计算机上运行它们。

我能够在本地构建应用程序,并且一切运行顺利。

在此方面的任何帮助都会很棒。预先感谢。

docker nginx flask docker-compose uwsgi
2个回答
0
投票

对于您的第一个问题,您的假设是错误的。没有“一幅图片”涵盖了组合中的所有服务。每个服务都有自己的图像。

对于无互联网分发问题...您可以使用本地注册表,以前在其中加载了所有基本依赖项(python,nginx容器...)。>


0
投票

不是我会推荐的,但是您可以

© www.soinside.com 2019 - 2024. All rights reserved.