Im unable to display my prestashop backup contents in the web browser

So, to put in context, I’ve been trying to restore a backup that I made of my prestashop that was hosted in a VM, both the prestashop and mariadb were on the same system.
The db is hosted in another container that contains it’s proper backup when was hosted in the VM

Here is the prestashop Image I’ve been doing (Ipaddres=, upated):

FROM prestashop/prestashop:1.7

#Expose port 443 to be accessed
EXPOSE 443/tcp

#copy the backup file that you want to restore into the Docker image and the config
RUN mkdir /root/backup/
COPY /root/backup/

#sets de DB passwd to debian (default uses root user)
#To be determined IP address, for the moment i'll put the ip address of my db running container
#I don't know for a fact but i think these env are not beeing used
#sets de db name, default prestashop, I'm using this one
ENV DB_NAME=prestashop_asix
#auto installs image with ssl enabled

#script that restores the backup
RUN set -eux && \
    apt-get update && \
    apt-get install -y unzip openssl wget systemctl nano && \
    rm -rf /var/www/html/* && \
    unzip /root/backup/ -d /var/www/html && \
    rm -rf /root/backup/ && \
    chmod -R 755 /var/www/html/presta_backup
#This script installs the unzip utility, unzips the backup file, 
#and moves the contents of the backup to the /var/www/html directory, 
#which is the default web root for PrestaShop.

#generates the certificate and key necessary for the https site
#modify -subj values to your liking
RUN openssl req \
    -x509 -nodes -newkey rsa:4096 -keyout /etc/ssl/private/key.pem \
    -out /etc/ssl/certs/cert.crt -sha256 -days 365 \
    -subj '/C=US/ST=Oregon/L=Portland/' 

#copies the site to the config
RUN rm -rf /etc/apache2/sites-available/
COPY https.conf /etc/apache2/sites-available/

RUN echo "ServerName" >> /etc/apache2/apache2.conf && \
    echo "<Directory /var/www/html/presta_backup>\n\tOptions Indexes FollowSymLinks\n\tAllowOverride None\n\tRequire all granted\n</Directory>" >> /etc/apache2/apache2.conf

RUN chown www-data:www-data -R /var/www/html/presta_backup/
RUN a2enmod ssl
RUN a2ensite https.conf
RUN apache2ctl configtest 
RUN systemctl start apache2

#TO implment
#I changed /etc/apache2/apache2.conf -> <Directory /var/www/html/presta_backup>
#maybe is something wrong with .htaccess?

the mariadb image (it restores a logical backup - ipaddress=

FROM mariadb:10.5.18

COPY my_backup.sql /docker-entrypoint-initdb.d/


I’ve tried using --link when runing the prestashop image in a container but does not seem to work, I still get the same erro checking docker logs (Checking if is available… \n Waiting for confirmation of MySQL service startup)

the .htaccess file:

# ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again
# .htaccess automaticaly generated by PrestaShop e-commerce open-source solution
# -

<IfModule mod_rewrite.c>
<IfModule mod_env.c>

RewriteEngine on

RewriteRule . - [E=REWRITEBASE:/]
RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]

# AlphaImageLoader for IE and fancybox
RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 [L]

AddType application/ .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/font-woff .woff
AddType font/woff2 .woff2
<IfModule mod_headers.c>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg)$">
		Header set Access-Control-Allow-Origin "*"

    <FilesMatch "\.pdf$">
      Header set Content-Disposition "Attachment"
      Header set X-Content-Type-Options "nosniff"

<Files composer.lock>
    # Apache 2.2
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all

    # Apache 2.4
    <IfModule mod_authz_core.c>
        Require all denied
#If rewrite mod isn't enabled
ErrorDocument 404 /index.php?controller=404

# ~~end~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again

using docker logs I’ve realised, that it can not connect to the db:
Checking if is available…

  • Waiting for confirmation of MySQL service startup

maybe the solutions is to link both container?

The first post is quite hard to read. Please format the first post according these instructions: How to format your forum posts

1 Like

Thank you for reformating the post. Now it’s easier to read :slight_smile:

1 Like

One thing that immediately hits the eye is that your Dockerfiles have environment specific configuration. Instead of hard coding environment specific configuration in the image, you want to create an entrypoint script that leverage ENV variables you configured for the container to update configuration files.

If you communicate to other containers by ip addresses, then you are high likely trying to do something that is not really meant to be done like this.

I assume you configure your containers using a docker compose file. If you don’t, I strongly recommend beginning using them, as they can be stored in the same git repo and make the container configuration reproducible.

Now I will look more in depth to your first post.

Okay, thanks, I’ll have to check on using ENV variables and a docker-compose file, I’m still learning so it might take some time :sweat_smile:

If you share your docker run commands that you use to create your containers, we can help you to turn them into a compose file.

Have you checked if the prestashop container already provides extensibility by design? Most images allow to map volumes or host folders into container folders and use environment variables to customize the application inside the container.

Sure, the docker run command im using for prestashop:

sudo docker run -itd --name prestashopv1 -p 4443:443 --link mariadb:prestashop_asix presta:backup1

(presta:backup1 is the image that I’m generating)

and the docker run command for mariadb:

sudo docker run -itd --name mariadb mariadb:backup

(where mariadb:backup is the image I’ve generated)

And yeah, I’ve checked if the container provided extensibility, I’m currently using prestashop/prestashop:1.7 which does not feature that, I also tried using bitnami/prestashop but was not able to restore the backup, I think the problem resides on the backup itself, i can send the files that I’ve modified if needed.
Perhaps It could also be some bug regarding prestashop installation since I’m enabling auto install?

The compose file for the v2 version of docker compose would look something like this:

Copy the content into a file called compose.yml or docker-compose.yml. Modify to your needs, for instance I used placeholder for host paths of the volume mapping, yours will most likely look different.

    container_name: prestashopv1
    image: presta:backup1
    restart: unless-stopped
      default: {}
      - 4443:443
      DB_SERVER: db
      DB_USER: root
      DB_PASSWD: debian
      DB_NAME: prestashop_asix
      - ./backup:/root/backup/
      # probably more binds or volumes ./prestahop:-
    image: mariadb:10.5.18
    restart: unless-stopped
      default: {}
      - 3307:3306
      # this is a docker named volume (manged by docker, mounted into a container folder)
      - mariadb-data:/var/lib/mysql
      # this is a bind (=host folder bind-mount into a containerf)
      - ./my_backup.sql:/docker-entrypoint-initdb.d/my_backup.sql

    name: prestashop-net

  mariadb-data: {}

Then run docker compose up to see if the containers start as expected. if they do, you can press ctrl+c and then start the deployment detached: docker compose up -d. If you do changes on the compose file, just use the last command again and a new container will be deployed with the changes.

With docker compose, the containers would be attached to a user defined network and therefor can use the dns-based service discovery. The default bridge network does not support service discovery and required links because of that - links are deprecated.

Of course this snippet from above is just to give you an idea. Since your docker run commands didn’t really provide much parameters, there was not much to work with.

The idea is to get you started. If you encounter problem, try to solve them on your own (see document links below), if you can’t paste what you did and the error message and we can see.

You can find the docs for the compose specification here:

You can find the docker compose documentation here:

1 Like

With the help of a friend I finally managed to do it, I’ll put it here in case somebody ever comes across this same issue:
Please note that this only works on my environment, and comments are in Spanish

#Importa la última versión de la imagen de debian disponible en docker-hub
FROM debian:latest

#crea un directorio donde va a copiar el backup
RUN mkdir /root/backup/
COPY hola.tgz /root/backup/

#actualiza, instala dependencias, borra contenidos predeterminados en /html, descomprime el backup en /www, borra el backup comprimido
#cambia parámetreos de archivos de config necesarios
#borra /cache/prod puesto que no es necesario y se autoregenera
RUN set -eux && \
	apt-get update && \ 
    apt-get install php libapache2-mod-php7.4 php7.4-curl php7.4-xml php7.4-gd php7.4-intl php7.4-mbstring php7.4-zip php7.4-mysql unzip openssl wget systemctl nano sed tar -y && \
    rm -rf /var/www/html/* && \
    tar -xvzf /root/backup/hola.tgz -C /var/www/ && \
    rm -rf /root/backup/hola.tgz && \
    find /var/www/html/presta_dir -type f -exec sed -i "s/'database_host' => ''/'database_host' => ''/g" {} \; && \
    find /var/www/html/presta_dir -type f -exec sed -i "s/'database_port' => ''/'database_port' => '3306'/g" {} \; && \
    find /var/www/html/presta_dir -type f -exec sed -i "s/'database_user' => 'db_user'/'database_user' => 'root'/g" {} \; && \
    rm -rf /var/www/html/presta_dir/var/cache/prod/* 

#chmod -R 755 /var/www/html/presta_backup - no hace falta esto

#genera certificados y keys para https
RUN openssl req \
    -x509 -nodes -newkey rsa:4096 -keyout /etc/ssl/private/key.pem \
    -out /etc/ssl/certs/cert.crt -sha256 -days 365 \
    -subj '/C=US/ST=Oregon/L=Portland/'

#borra los sitios y añade https.conf que pilla cert y key generados anteriormente
RUN rm -rf /etc/apache2/sites-available/
COPY https.conf /etc/apache2/sites-available/

#añade parámetros necesarios en apache2.conf
RUN echo "ServerName" >> /etc/apache2/apache2.conf && \
    echo "<Directory /var/www/html/presta_dir>\n\tOptions Indexes FollowSymLinks\n\tAllowOverride None\n\tRequire all granted\n</Directory>" >> /etc/apache2/apache2.conf

#habilita ssl
RUN a2enmod ssl

#habilita php7.4
RUN a2enmod php7.4

#habilita lbmethod_byrequests
RUN a2enmod lbmethod_byrequests

#cambia owner de presta_dir, habilita https.conf y comprueba que la sintaxis de la configuración esté bien
RUN chown www-data:www-data -R /var/www/html/presta_dir/ && \
    a2ensite https.conf && \
    apache2ctl configtest 

#expone el puerto 443

#ejecuta apache en primer plano detached, para hacer que el contenedor no se detenga o tener que forzarlo a que no se detenga
CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]