How do you persist the installation on a Magento Docker container? - wordpress

I am busy setting up a dockerized environment to develop PHP for Magento.
The image I am using is the following: alexcheng/magento2.
The git repository for this does contain an install script.
When I run "docker-compose up -d" everything works fine but I have to install Magento afresh each time the container goes down.
Any advice for how to deal with this? I am a relative newb at using docker but I can't imagine that you would have to reinstall it each time.
Note, I don't think this has to do with data persistence as a volume has been provisioned. When I include a line in the Dockerfile "RUN install-magento" I get the following error when building:
/usr/bin/env: ‘bash\r’: No such file or directory
The command '/bin/sh -c install-magento' returned a non-zero code: 127
Any guidance would be appreciated. Thank you.

I'm newbie about Docker as you. I suggest that you learn docker before wildly uses docker-compose tool. When we need data persistence the way is to use docker volumes.
Check if your docker-compose.yml have a volume section and if your user have permission on that path.

Related

Unable to install IIS AspNetCoreModuleV2 in a dockerimage (and Azure Pipelines)

I have a problem for few days now with the "dotnet hosting bundle" and AspNetCoreV2 IIS module in a dockerimage.
So, I creating a dockerimage with many IIS modules and requirements to execute our software. The dockerimage works good expect this AspNetCoreV2 module. When the container created, I check the modules installed with Get-WebGlobalModule and doesn't appear.
But, when I start the quiet (or passive) installation manualy, into the container, this module works and appear in the IIS Module list.
I tried many solutions to do that (multistage with aspnetcore Microsoft images, last version of dotnet_hosting_bundle.exe and many other, but same issue).
I tried to automatise the docker exec process to install this module manualy and commit it with Azure Pipelines and Windows agent in a VM, but doesn't work :(.
To try that, I use different way :
docker stop mycontainer
docker rm mycontainer
docker run --name mycontainer -d -it $(containerRegistry)/$(container_requirement_name):v1.0.$(Build.BuildId)
docker exec mycontainer powershell.exe -command Start-Process -FilePath 'C:\Program Files\MySoftware\PowerShell\Installer.Prerequisites\dotnet-hosting-3.1.2-win.exe' -ArgumentList "/passive","/install","/norestart" -PassThru -Wait
docker stop mycontainer
docker commit mycontainer $(containerRegistry)/$(container_requirement_name):v1.0.$(Build.BuildId).1
In the Start-Process, I can see :
The process is created but apparently not started
I also tried with : cmd 'C:\Program Files\MySoftware\PowerShell\Installer.Prerequisites\dotnet-hosting-3.1.2-win.exe' /quiet /install
This task in Azure Pipeline working without error, but when I download this new image (pushed after these instructions), the module doesn't appear in Get-WebGlobalModule
Also, the module is not presend into ProgramFiles
I don't really understand how can I install this module. All other modules working, expect this ...
Thanks you very much in advance for your advises.
Best
Set the preference variables with below command fixed above issue.
powershell -Command $ErrorActionPreference = 'Stop' $ProgressPreference = 'Continue'
The values of the preference variables affect how PowerShell operates and executes cmdLets. It might be because the default settings of the preference variables of the container that caused the PowerShell failing to complete the installation. You can override these preference variables in your script.
Please see this document for more information about Preference Variables.

Symlink lost within Docker image

I am defining a Dockerfile where I install sqlite3 in a ubuntu based image, something very similar (I also install grpc and rust as well as all the necessary dependencies) to:
FROM ubuntu
RUN apt-get update && \
apt-get install -y sqlite3 libsqlite3-dev&& \
apt-get clean && \
apt-get autoremove
I use this image to built my Rust project within it. The issue that I am facing is that cargo build fails on my GitLab CI due to a linking issue:
Compiling migrations_macros v1.4.0
error: linking with `cc` failed: exit code: 1
...
= note: /usr/bin/ld: cannot find -lsqlite3
I found out that this is due to this symlink not being present on the Docker image that is running on CI:
libsqlite3.so -> /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
while the file libsqlite3.so.0.8.6 exists. So if I create the symlink during the CI jobs I can have a working workaround. The weird thing is that if I pull the same exact image from my registry on my pc and run the container I can build without any issue and any change because the symlink is actually there.
What could be the cause of the problem and how to solve it?
After quite a bit of thinking the following ideas come to my mind which could help.
Docker history
Docker command has a build in feature to view the history of a built image. You have the option to identify the problematic command in the DockerFile.
docker history <image id or name>
For more visual filtering i do recommend dive tool but others are also available on google.
Correct docker version
Since in this scenario the two docker instances are different the question is trivial. Are they on the same version of docker daemon and docker file system driver?

ASP.NET with Linux Docker autogenerated "Service 'failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder"

Many people asking about problem with
Service 'web' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder
This problem exist, when you trying to build Docker image from autogenerated Dockerfile for Linux in Visual Studio. I resolved that. Because many questions are not connected with ASP.NET directly i will help you, and tell what to do in this case in answer.
I tried to change:
COPY ["Divorcer/Divorcer.csproj", "Divorcer/"] to:
COPY ["/Divorcer/Divorcer.csproj", "Divorcer/"],
COPY ["./Divorcer/Divorcer.csproj", "Divorcer/"],
even to
COPY ["~/.Divorcer/Divorcer.csproj", "Divorcer/"]
Problem still exist.
So, as i told you Randomly generated path is like above.
Solution is in Solution. When you creating new project named "Divorcer" VStudio making
Solution
-- Project
Directories. This problem was resolved with simply bash commands (if you using screen OS you can do it with your mouse).
cd /Path/To/Solution/Project
mv Dockerfile ../
Its simply coping Dockerfile to Solution directory from Project directory. Now you can use docker build -t "someproject" . and it working.
Make sure that you are in Solution directory! Have fun.

How do I give my app directory the correct permissions in order to run docker-compose up?

I am very new to Docker Images. I have therefore been following a tutorial about how to run Docker Image for Meteor Apps. It seems like I managed to install the Base Docker Image for Meteor Apps from https://hub.docker.com/r/geoffreybooth/meteor-base/ which I now am having issues running on my remote server while using the docker-compose up command.
The below is what I get after running docker-compose up:
I thought using sudo docker-compose up might help but I still get the following:
Can someone kindly help point out how to resolve this issue.
Find below my environment details, hopefully you will find them of use in the attempt to help me:
I thought there might be something wrong with my docker installation so I run: sudo docker run hello-world but the message: Hello from Docker!
This message shows that your installation appears to be working correctly.... suggests that the installation is fine.
$ docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
Find below the contents of my folder. Note that the app is the folder containing my app.
$ ls
Dockerfile app docker-compose.yml
The content of Dockerfile is copied and pasted from Dockerfile content:
The content of docker-compose.yml is copied and pasted from docker-compose.yml
also the contents of .dockerignore is copied and pasted from .dockerignore.
Kindly let me know if there is any other environment that I need to expose.
Looking forward to your help.

Running rocket.chat on docker composer. Where are source codes?

This is probably a stupid question but I am running rocket.chat deployed w/ docker compose. I'm trying to customize the app but I don't know where to access the source codes. I don't really have full grasp of what docker is. Their docs are too confusing for me to understand. Any help? Can anyone direct me to the right direction?
Usually the files are stored on a folder that is specified in the Dockerfile. In the case of Rocket.Chat, this is the /app folder, inside the container.
I strongly suggest you do not edit source files directly inside your docker container. Rocket.Chat files inside a container are a compiled version and not the original source files.
If you still need access to that container files, you can access your container by running:
docker exec -it _your_container_name_ /bin/sh

Resources