I'm very new to the container world and docker but feel its the technology I need to leverage due to specific infrastructure limitations on a project I'm working on.
I'm trying to build my application my Windows 10 machine and then migrate that over to another Windows 10 computer that lives on another network that has no internet access and has no communication out (I can only push/pull from my main network). The application is a Flask Application running on a uWsgi/nginx server.
I followed some tutorials around docker and docker compose and came up with the following application structure:
Application
- flask
- app
- env
- Dockerfile
- app.config
- run.py
- nginx
- Dockerfile
- nginx.conf
- docker-compose.yml
Contents of the docker compose file:
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
Contents of the 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"]
Contents of the 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
Contents of the nginx Dockerfile: FROM 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
Contents of the 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;
}
}
When using docker-compose build I get multiple images built which I thought would not be the desired outcome? I guess I was thinking it would be a single image which could then be moved and ran else where.
The issue though is how about going about moving the images and running them on the computer with no internet access.
I am able to build the application locally and everything works swimmingly.
Any help on this would be great. Thanks in advance.
For your first question, your assumption is wrong. There is no "one image" that covers all the services in the compose. Each service is going to have its own image.
For the distributing without internet question... You can use a local registry in which you have previously loaded all the base dependencies (python, nginx containers...) that you have.