In my use case, I am trying to run a multi-container app where each container will have its own port (one of the containers/ports is for uploading files in a separate thread). I could break this up into 2 different containers, but I am trying to avoid that. I have spent a week trying different techniques - I am hoping that someone can point me in the right direction.
I can see that Azure "Web App" allows for multi-containers, but the limitation here is that does not allow for custom ports.
I can see that Azure Container apps allow for custom ports, but in the setup you need to specify a single image.
Here is my docker-compose.
version: '3.8'
volumes:
db-data:
uploads:
services:
redis:
image: redis:alpine
ports:
- '6379:6379'
python-server:
image: <custom image name>:latest
privileged: true
build:
context: .
dockerfile: dockerfile
working_dir: /
ports:
- '8080:8080'
- '8050:8050'
env_file: .env
volumes:
- db-data:/instance/
- uploads:/persistence/uploads/
In my Dockerfile I am trying to expose 8050 for the uploads:
FROM python:3.11
WORKDIR /
# Install dependencies
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Copy your application code
COPY . .
VOLUME /instance/
VOLUME /persistence/uploads/
# Expose ports
EXPOSE 8080
EXPOSE 8050
# Run the server command
CMD ["./run-app.sh"]
Azure Web App for Containers doesn't allow you to specify custom ports for individual containers within a multi-container setup. It automatically maps the exposed ports of your containers to the default HTTP port 80 (or HTTPS port 443 if SSL is enabled).
Create an Azure Container Registry where you'll store your Docker images.
Create a configuration file that describes your multi-container application. In this file, specify the details of your containers
aci.yaml :
After deployment, to access the ports exposed by the Azure Container Instances (ACI), we can use the public IP address assigned to your ACI instance along with the specified port numbers.
20.9.120.152along with port8080to access the Python server:http://20.9.120.152:8080.20.9.120.152along with port8050to access the File upload functionality:http://20.9.120.152:8050.