Image upload not working on Amazon ECS but works fine on localhost (docker container) #2349

Closed
opened 2026-02-05 03:45:24 +03:00 by OVERLORD · 8 comments
Owner

Originally created by @HeavenlyEntity on GitHub (Aug 6, 2021).

Expected

I expect the image upload to work when changing the workspace logo also user profile images.

Actual Behavior

I am using docker compose to spin up the container with the following storage ENVs:

- STORAGE_TYPE=local
- STORAGE_IMAGE_TYPE=local
- STORAGE_ATTACHMENT_TYPE=local_secure

This instance works perfectly on my own machine but when I go to upload an image on the deployed container I get:
image

I made sure to include
RUN chown www-data:www-data -R /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage && chmod -R 755 /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage
in my Dockerfile in case it was a permissions thing on the host. Yet still, this is working on my own machine. Can anyone help figure out what the underlying issue is? Using the solidnerd docker image.

Host Details:
Using AWS ECS cluster following the docker context use ... & docker compose up to automate all the deployment processes and pre-reqs.

Originally created by @HeavenlyEntity on GitHub (Aug 6, 2021). ### Expected I expect the image upload to work when changing the workspace logo also user profile images. ### Actual Behavior I am using `docker compose` to spin up the container with the following storage ENVs: ``` - STORAGE_TYPE=local - STORAGE_IMAGE_TYPE=local - STORAGE_ATTACHMENT_TYPE=local_secure ``` This instance works perfectly on my own machine but when I go to upload an image on the deployed container I get: ![image](https://user-images.githubusercontent.com/39228141/128529276-d3c6b6ab-ac4e-4445-97bd-e136a7a6dcbe.png) I made sure to include `RUN chown www-data:www-data -R /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage && chmod -R 755 /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage ` in my *Dockerfile* in case it was a permissions thing on the host. Yet still, this is working on my own machine. Can anyone help figure out what the underlying issue is? Using the [solidnerd](https://github.com/solidnerd/docker-bookstack) docker image. Host Details: Using AWS ECS cluster following the `docker context use ...` & `docker compose up` to automate all the deployment processes and pre-reqs.
Author
Owner

@ssddanbrown commented on GitHub (Aug 8, 2021):

Hi @HeavenlyEntity,
What operating system are you using on AWS? And does this occur if you don't pass/set the volumes to the host?

Just wondering if something like selinux is at play here.

@ssddanbrown commented on GitHub (Aug 8, 2021): Hi @HeavenlyEntity, What operating system are you using on AWS? And does this occur if you don't pass/set the volumes to the host? Just wondering if something like selinux is at play here.
Author
Owner

@HeavenlyEntity commented on GitHub (Aug 9, 2021):

Hi @HeavenlyEntity,
What operating system are you using on AWS? And does this occur if you don't pass/set the volumes to the host?

Just wondering if something like selinux is at play here.

Not sure tbh but looking at my Dockerfile I see:

FROM alpine:3 as bookstack
ENV BOOKSTACK_VERSION=21.05.2
RUN apk add --no-cache curl tar
RUN set -x; \
    curl -SL -o bookstack.tar.gz https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz  \
    && mkdir -p /bookstack \
    && tar xvf bookstack.tar.gz -C /bookstack --strip-components=1 \
    && rm bookstack.tar.gz

FROM php:7.4-apache-buster as final
RUN set -x; \
    apt-get update \
    && apt-get install -y --no-install-recommends \
        git \
        zlib1g-dev \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng-dev  \
        libldap2-dev  \
        libtidy-dev  \
        libxml2-dev  \
        fontconfig  \
        fonts-freefont-ttf   \
        wkhtmltopdf  \
        tar \
        curl \
        libzip-dev \
        unzip \
    \
   && docker-php-ext-install -j$(nproc) dom pdo pdo_mysql zip tidy  \
   && docker-php-ext-configure ldap \
   && docker-php-ext-install -j$(nproc) ldap \
   && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
   && docker-php-ext-install -j$(nproc) gd

RUN a2enmod rewrite remoteip; \
    { \
    echo RemoteIPHeader X-Real-IP ; \
    echo RemoteIPTrustedProxy 10.0.0.0/8 ; \
    echo RemoteIPTrustedProxy 172.16.0.0/12 ; \
    echo RemoteIPTrustedProxy 192.168.0.0/16 ; \
    } > /etc/apache2/conf-available/remoteip.conf; \
    a2enconf remoteip

RUN set -ex; \
    sed -i "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf; \
    sed -i "s/VirtualHost *:80/VirtualHost *:8080/" /etc/apache2/sites-available/*.conf

COPY bookstack.conf /etc/apache2/sites-available/000-default.conf

COPY --from=bookstack --chown=33:33 /bookstack/ /var/www/bookstack/
# Added this line bc of file upload not working. ⬇
RUN chown www-data:www-data -R /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage && chmod -R 755 /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage

ARG COMPOSER_VERSION=1.10.16
RUN set -x; \
    cd /var/www/bookstack \
    && curl -sS https://getcomposer.org/installer | php -- --version=$COMPOSER_VERSION \
    && /var/www/bookstack/composer.phar global -v require hirak/prestissimo \
    && /var/www/bookstack/composer.phar install -v -d /var/www/bookstack/ \
    && /var/www/bookstack/composer.phar global -v remove hirak/prestissimo \
    && rm -rf /var/www/bookstack/composer.phar /root/.composer \
    && chown -R www-data:www-data /var/www/bookstack

COPY php.ini /usr/local/etc/php/php.ini
COPY docker-entrypoint.sh /bin/docker-entrypoint.sh

WORKDIR /var/www/bookstack

# www-data
USER 33

VOLUME ["/var/www/bookstack/public/uploads","/var/www/bookstack/storage/uploads"]

ENV RUN_APACHE_USER=www-data \
    RUN_APACHE_GROUP=www-data

EXPOSE 8080

ENTRYPOINT ["/bin/docker-entrypoint.sh"]

ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.build-date=$BUILD_DATE \
      org.label-schema.docker.dockerfile="/Dockerfile" \
      org.label-schema.license="MIT" \
      org.label-schema.name="bookstack" \
      org.label-schema.vendor="solidnerd" \
      org.label-schema.url="https://github.com/solidnerd/docker-bookstack/" \
      org.label-schema.vcs-ref=$VCS_REF \
      org.label-schema.vcs-url="https://github.com/solidnerd/docker-bookstack.git" \
      org.label-schema.vcs-type="Git"

Looks to be using Linux of some kind tho. There isn't any way for me to find out on AWS ECS, it shows the containers running as a service. There is no EC2 instance nor sign of one. But I do know the launch type is FARGATE.

Volumes are being made here for uploads and public for file uploads. Was told if there wasn't any upload volumes, creating books and shelves won't work as well.

@HeavenlyEntity commented on GitHub (Aug 9, 2021): > Hi @HeavenlyEntity, > What operating system are you using on AWS? And does this occur if you don't pass/set the volumes to the host? > > Just wondering if something like selinux is at play here. Not sure tbh but looking at my Dockerfile I see: ```DOCKERFILE FROM alpine:3 as bookstack ENV BOOKSTACK_VERSION=21.05.2 RUN apk add --no-cache curl tar RUN set -x; \ curl -SL -o bookstack.tar.gz https://github.com/BookStackApp/BookStack/archive/v${BOOKSTACK_VERSION}.tar.gz \ && mkdir -p /bookstack \ && tar xvf bookstack.tar.gz -C /bookstack --strip-components=1 \ && rm bookstack.tar.gz FROM php:7.4-apache-buster as final RUN set -x; \ apt-get update \ && apt-get install -y --no-install-recommends \ git \ zlib1g-dev \ libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ libldap2-dev \ libtidy-dev \ libxml2-dev \ fontconfig \ fonts-freefont-ttf \ wkhtmltopdf \ tar \ curl \ libzip-dev \ unzip \ \ && docker-php-ext-install -j$(nproc) dom pdo pdo_mysql zip tidy \ && docker-php-ext-configure ldap \ && docker-php-ext-install -j$(nproc) ldap \ && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \ && docker-php-ext-install -j$(nproc) gd RUN a2enmod rewrite remoteip; \ { \ echo RemoteIPHeader X-Real-IP ; \ echo RemoteIPTrustedProxy 10.0.0.0/8 ; \ echo RemoteIPTrustedProxy 172.16.0.0/12 ; \ echo RemoteIPTrustedProxy 192.168.0.0/16 ; \ } > /etc/apache2/conf-available/remoteip.conf; \ a2enconf remoteip RUN set -ex; \ sed -i "s/Listen 80/Listen 8080/" /etc/apache2/ports.conf; \ sed -i "s/VirtualHost *:80/VirtualHost *:8080/" /etc/apache2/sites-available/*.conf COPY bookstack.conf /etc/apache2/sites-available/000-default.conf COPY --from=bookstack --chown=33:33 /bookstack/ /var/www/bookstack/ # Added this line bc of file upload not working. ⬇ RUN chown www-data:www-data -R /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage && chmod -R 755 /var/www/bookstack/bootstrap/cache /var/www/bookstack/public/uploads /var/www/bookstack/storage ARG COMPOSER_VERSION=1.10.16 RUN set -x; \ cd /var/www/bookstack \ && curl -sS https://getcomposer.org/installer | php -- --version=$COMPOSER_VERSION \ && /var/www/bookstack/composer.phar global -v require hirak/prestissimo \ && /var/www/bookstack/composer.phar install -v -d /var/www/bookstack/ \ && /var/www/bookstack/composer.phar global -v remove hirak/prestissimo \ && rm -rf /var/www/bookstack/composer.phar /root/.composer \ && chown -R www-data:www-data /var/www/bookstack COPY php.ini /usr/local/etc/php/php.ini COPY docker-entrypoint.sh /bin/docker-entrypoint.sh WORKDIR /var/www/bookstack # www-data USER 33 VOLUME ["/var/www/bookstack/public/uploads","/var/www/bookstack/storage/uploads"] ENV RUN_APACHE_USER=www-data \ RUN_APACHE_GROUP=www-data EXPOSE 8080 ENTRYPOINT ["/bin/docker-entrypoint.sh"] ARG BUILD_DATE ARG VCS_REF LABEL org.label-schema.build-date=$BUILD_DATE \ org.label-schema.docker.dockerfile="/Dockerfile" \ org.label-schema.license="MIT" \ org.label-schema.name="bookstack" \ org.label-schema.vendor="solidnerd" \ org.label-schema.url="https://github.com/solidnerd/docker-bookstack/" \ org.label-schema.vcs-ref=$VCS_REF \ org.label-schema.vcs-url="https://github.com/solidnerd/docker-bookstack.git" \ org.label-schema.vcs-type="Git" ``` Looks to be using Linux of some kind tho. There isn't any way for me to find out on AWS ECS, it shows the containers running as a service. There is no EC2 instance nor sign of one. But I do know the launch type is FARGATE. Volumes are being made here for uploads and public for file uploads. Was told if there wasn't any upload volumes, creating books and shelves won't work as well.
Author
Owner

@ssddanbrown commented on GitHub (Aug 12, 2021):

Thanks for the confirmation @HeavenlyEntity. To be honest I had EC2 and ECS mixed up. I have no idea how ECS works, From searching the storage side of things looks pretty complex. Are you doing something specific on the AWS side to supply/mount the storage/volume?

@ssddanbrown commented on GitHub (Aug 12, 2021): Thanks for the confirmation @HeavenlyEntity. To be honest I had EC2 and ECS mixed up. I have no idea how ECS works, From searching the storage side of things looks pretty complex. Are you doing something specific on the AWS side to supply/mount the storage/volume?
Author
Owner

@HeavenlyEntity commented on GitHub (Aug 13, 2021):

No I just followed the instructions on your docs. But if you look at the
Dockerfile it shows the setting of the volumes but in my docker compose
file its the same as the default set up on the *solidnerd *repo only things
that were added were the environment variables.

On Thu, Aug 12, 2021, 1:06 PM Dan Brown @.***> wrote:

Thanks for the confirmation @HeavenlyEntity
https://github.com/HeavenlyEntity. To be honest I had EC2 and ECS mixed
up. I have no idea how ECS works, From searching the storage side of things
looks pretty complex. Are you doing something specific on the AWS side to
supply/mount the storage/volume?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BookStackApp/BookStack/issues/2874#issuecomment-897932489,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJLJF3LT3BVCQQBUGVF2EO3T4QSU3ANCNFSM5BWCLDSQ
.

@HeavenlyEntity commented on GitHub (Aug 13, 2021): No I just followed the instructions on your docs. But if you look at the Dockerfile it shows the setting of the volumes but in my docker compose file its the same as the default set up on the *solidnerd *repo only things that were added were the environment variables. On Thu, Aug 12, 2021, 1:06 PM Dan Brown ***@***.***> wrote: > Thanks for the confirmation @HeavenlyEntity > <https://github.com/HeavenlyEntity>. To be honest I had EC2 and ECS mixed > up. I have no idea how ECS works, From searching the storage side of things > looks pretty complex. Are you doing something specific on the AWS side to > supply/mount the storage/volume? > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/BookStackApp/BookStack/issues/2874#issuecomment-897932489>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AJLJF3LT3BVCQQBUGVF2EO3T4QSU3ANCNFSM5BWCLDSQ> > . >
Author
Owner

@ssddanbrown commented on GitHub (Aug 13, 2021):

Sure, the dockerfile defines some volumes but where/how do they map to outside of the container? From a quick search is that where efs comes in to play? https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html
Again though, I have no idea about this part of AWS, always find these kind of hosted services to be more trouble than they're worth for the kind of things I run.

@ssddanbrown commented on GitHub (Aug 13, 2021): Sure, the dockerfile defines some volumes but where/how do they map to outside of the container? From a quick search is that where efs comes in to play? https://docs.aws.amazon.com/AmazonECS/latest/developerguide/efs-volumes.html Again though, I have no idea about this part of AWS, always find these kind of hosted services to be more trouble than they're worth for the kind of things I run.
Author
Owner

@ssddanbrown commented on GitHub (Sep 29, 2021):

Since there's been no follow-up I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.

@ssddanbrown commented on GitHub (Sep 29, 2021): Since there's been no follow-up I'm going to close this. If the issue remains and is something you still require to be fixed please open a new issue, referencing this one.
Author
Owner

@HeavenlyEntity commented on GitHub (Oct 8, 2021):

Yes it still needs to be fixed. Nobody has commented on it because they
don't know or don't understand what is happening.

On Wed, Sep 29, 2021 at 12:54 PM Dan Brown @.***> wrote:

Since there's been no follow-up I'm going to close this. If the issue
remains and is something you still require to be fixed please open a new
issue, referencing this one.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BookStackApp/BookStack/issues/2874#issuecomment-930494593,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AJLJF3P7DR2WIM7U7THT5V3UENVF3ANCNFSM5BWCLDSQ
.

@HeavenlyEntity commented on GitHub (Oct 8, 2021): Yes it still needs to be fixed. Nobody has commented on it because they don't know or don't understand what is happening. On Wed, Sep 29, 2021 at 12:54 PM Dan Brown ***@***.***> wrote: > Since there's been no follow-up I'm going to close this. If the issue > remains and is something you still require to be fixed please open a new > issue, referencing this one. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/BookStackApp/BookStack/issues/2874#issuecomment-930494593>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AJLJF3P7DR2WIM7U7THT5V3UENVF3ANCNFSM5BWCLDSQ> > . >
Author
Owner

@ssddanbrown commented on GitHub (Oct 8, 2021):

@HeavenlyEntity If you're able to advise what i required to be changed in BookStack to fix your specific problem then feel free to open a new issue, referencing this one, with detail regarding the solution and problem it solves.
From my point of view this very much appears to be an issue related to hosting. We can only provide so much support when it comes to more complex hosting arrangements such as ECS. There has been no follow up attempts at providing details of if/how volumes are mapped outside the container which is the only obvious avenue I could see to resolve this.

@ssddanbrown commented on GitHub (Oct 8, 2021): @HeavenlyEntity If you're able to advise what i required to be changed in BookStack to fix your specific problem then feel free to open a new issue, referencing this one, with detail regarding the solution and problem it solves. From my point of view this very much appears to be an issue related to hosting. We can only provide so much support when it comes to more complex hosting arrangements such as ECS. There has been no follow up attempts at providing details of if/how volumes are mapped outside the container which is the only obvious avenue I could see to resolve this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2349