Reputation: 13
I would like to make my applications available as All-In-One Docker. I came across the idea of running Docker-Compose in a Docker container. The built image is running, but I cannot mount any volumes via the file path to the internal compose services within the image.
Mount Folders and mount file nginx.conf is not found inside the container.
I was able to verify that the folders and files were copied or created in the container.
If there is another solution for running multiple services in an aio container, I would use that.
Error Message:
Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/app/icons/Logo.png" to rootfs at "/usr/share/nginx/html/Logo.png": mount /app/icons/Logo.png:/usr/share/nginx/html/Logo.png (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
Dockerfile:
FROM docker:23.0.1-cli-alpine3.17
# installdocker-compose
RUN apk add --no-cache docker-compose
# create directories
WORKDIR /app
RUN mkdir -p /app/icons
RUN mkdir -p /app/database
RUN mkdir -p /app/files
COPY docker-compose.yml .
COPY nginx.conf ./nginx.conf
COPY ./icons ./icons
ENV DOCKER_HOST=unix:///var/run/docker.sock
# default vars being reset at image start
ENV MYSQL_DATABASE=""
ENV MYSQL_USER=""
ENV MYSQL_PASSWORD=""
ENV MYSQL_ROOT_PASSWORD=""
EXPOSE 80 3306
# Standardbefehl: docker-compose starten
CMD ["docker-compose", "up"]
docker-compose.yml
version: '3.8'
services:
aio_reverse_proxy:
image: nginx:alpine
container_name: aio_reverse_proxy
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- aio_backend
- aio_frontend
ff_admin_aio_frontend:
image: frontend:latest
container_name: aio_frontend
restart: unless-stopped
ports:
- "80"
volumes:
- ./icons/Logo.png:/usr/share/nginx/html/Logo.png
aio_backend:
image: backend:latest
container_name: aio_backend
restart: unless-stopped
ports:
- "5000"
environment:
- DB_TYPE=mysql
- DB_HOST=aio_database
- DB_PORT=3306
- DB_NAME=${MYSQL_DATABASE}
- DB_USERNAME=${MYSQL_USER}
- DB_PASSWORD=${MYSQL_PASSWORD}
volumes:
- ./files:/app/files
networks:
- aio_internal
depends_on:
- aio_database
aio_database:
image: mariadb:11.2
container_name: aio_database
restart: unless-stopped
ports:
- "3306:3306"
environment:
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
volumes:
- ./database:/var/lib/mysql
networks:
- aio_internal
networks:
aio_internal:
nginx.conf
events { }
http {
server {
listen 80;
# redirect of /api/* to the backend
location /api/ {
proxy_pass http://aio_backend:5000/; # internal backend
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# redirect other requests to frontend
location / {
proxy_pass http://aio_frontend:80/; # internal frontend
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
usage of the aio-image
services:
aio:
image: aio:latest
container_name: aio
ports:
- "80:80"
environment:
- MYSQL_DATABASE=1234
- MYSQL_USER=1234
- MYSQL_PASSWORD=1234
- MYSQL_ROOT_PASSWORD=1234
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./files:/app/files
- ./database:/app/database
- ./icons/Logo.png:/app/icons/Logo.png # optional to replace default logo
I tried multiple filepaths including relative paths to the workdirectory like ./files or absolute paths like /app/files.
I also tried to run a container inside the image, that does not need a mount for startup, but creates the mounted directory inside the image. But I did not find any location the folder was created.
I was expecting some kind of mount path to work, but I didn't find one.
Upvotes: 0
Views: 29