Hello,
I want to install ojs using docker, I am not too professional with programming. I just followed the instuctions described in this link.
After that I filled out the form as mentioned in the link, but I got always this error: A database error has occurred: No such file or directory.
I tried to pull a mysql image to my docker and execute but it doesn’t resolve the issue.
The version of ojs is 3_2_0-1.
Hello @anouar2002,
Not entirely sure what’s happening here, but I do note that this docker tool is still in beta and undergoing development, as is noted on the Github repository. It specifically discourages using the tool in production. The developer of the tool @marc - may wish to weigh in, with any thoughts he might have on the use of this tool.
Best regards,
Roger
Hello @rcgillis,
Thanks for trying to help me. If I understand correctly, it will be preferable to install the OJS using another method, do you have any suggestion please ?
Kind regards,
Anouar
Official method is the one described in documentation (host classic installation) but you can also use docker if you like.
Some questions to help you with this:
- Did you use regular docker-compose or the local one?
- Are the docker-compose.yml volumes used and folders created?
- Did you fill the installation form with the right data? driver: mysqli, host: db, pwd: ojsPwd (or set in .env file)
Hello @marc,
Thanks for your reply. It will be easier for me to use the docker that’s why I will try to answer you:
I am not sure which one I am using but I used the command “docker compose up”
I created only a folder to upload the files (Directory of uploads) and give it the path in the form
Yes as described in the installation
Cheers,
Anouar
Hi @anouar2002
Sorry for the delay in my answer, I’m on xmas vacations.
As far as I can see, you did it in the right way.
Do you mind to publish the output of:
-
Docker and compose versions:
$ docker -v && docker-compose -v
-
Starting process log:
$ docker-compose logs
-
Status of the containers:
$ docker-compose ps"?
I guess something wired is happening with the DB container.
If you prefer sending me a tarball of your project I can take a look.
Take care,
m.
Hello @marc,
Firstly, happy new year !
No problem, I was also in vacation. Thanks for the reply !
Docker version 20.10.0, build 7287ab3
docker-compose version 1.27.4, build 40524192
There are 5 screenshots of logs :
I hope that I answered your questions. I will try to give more informations if you want.
Sorry I didn’t understand what you mean by tarball here.
Cheers,
Anouar
Hi @anouar2002,
I’m back to work, so now I hope I will be able to answer you faster.
Your log don’t shown anything wired and “docker-compose ps” shows that containers are up and running fine.
Are you still getting the error or now is fixed?
When I asked for a tarball I wanted a compressed version of your running folder.
I mean… a zip of the folder where you have the docker-compose.yml, the .env file and the volumes.
If you tell me you are running a “vanilla” version (I mean, a version without any personalization) tomorrow I will follow the readme instructions in my laptop to see if I can reproduce the error.
Thanks for your feedback and sorry for the delay,
m.
Hello @marc,
Thanks for the reply. No proble, I am glad that you have some time for this issue.
Unfortunately, I still getting the error of “**Errors occurred during installation: **
A database error has occurred: No such file or directory” in this way:
So I will describe briefly what I exactly did, maybe it can help you to recognize the problem:
I download the ojs folder (not clone it) from this link then I followed the instruction in the page as follow:
After that, I run the stack using the command “docker-compose up”.
In the Docker Desktop, I am getting these images:
And when I try to open the ojs_app_journal in the browser, I am receiving this error:
Thanks, it is clear. I attached here the “php73 folder” in this link (sorry the forum don’t accept the upload of zip/tar files), I am not if the correct one, but what I can guarantee that the one where I wrote the commands.
I hope that it is enough clear.
Yes I am running a vanilla version.
Thanks in advance,
Anouar
Your screenshots are really useful to understand what you did.
I’m quite confident the problem is in DB section when you set the Host, that need to be “db” instead of “localhost”.
To clarify this, in docker-compose you create 2 containers: one for ojs code and files (called “ojs”) the other for the database (called “db”) so you have to think in them as 2 independent machines.
When running the installation (ojs container) you can ask for the database in “localhost”… it need to be the “db” container.
I think this is pointed in the howto… but from your feedback it’s clear that need to be highlighted.
Try this change and tell us how it goes.
And please, come back if you get any trouble.
Hello @marc,
Thanks for replying me.
Sorry I am not familiar with docker, I don’t know how to create a container in docker-compose and give it a name. Any guide for that please ?
What I’ve tried is to create 2 folders “ojs” and “db” and copy the “ojs-docker-master” in each folder, then open 2 “cmd” and run the docker using “docker-compose” in each cmd. I think it is not what you mean by creating containers.
Tanks in advance,
Anouar
No need to sorry. We are all learning something.
Sorry if I didn’t explain myself… my English is really bad.
The point is now you don’t need to create anything else because those 2 containers are already created.
You created them when you did when you run “docker-compose up”.
To confirm this, you can see the two containers up and running here:
It also shows that the external name of the DB container is “ojs_db_journal” but this name is variable and in the docker-compose this container is also named as “db” so you can use any of both (I always use the docker-compose one to avoid errors).
You are amost done!
Good news now you only need to install your OJS filling “Host” field with “db” instead of “localhost” here:
But looks like you created two folders (ojs and db) and run “docker-compose” in both… so now you will have 6 containers (2 initial ones and 2x2 for the newly crated). Am I right?
The idea here is each folder is a different stack (and a stack include 2 containers… one for the code called “ojs” and the other with the database called “db”). Open your docker-compose.yml with your favorite editor and take a look because it’s quite easy to read it (but be sure to NOT edit. A single space in a yml file will break the file).
So, if you have 3 stacks (6 containers) we need to reverse it all and go back to the initial situation with a single stack (2 containers).
And first you need to stop and remove those 2 extra stacks doing the following (adapt to windows syntax if I made it wrong, please):
> cd ojs
> docker-compose stop
> docker-compose rm
> cd ..
> cd db
> docker-compose stop
> docker-compose rm
After this, if you will still have one additional folder from your initial project (not sure how you named it), you can safely remove the two extra folders that you created (ojs and db) and you will be back to the former scenario.
Let me be crystal clear: You will only need one folder (the initial one that will start 2 containers called “ojs_app_journal” and “ojs_db_journal” up and running) as you perfectly did at the beginning.
If it’s not the case, remove everything, stop everything and start with the howto till you get a single stack with the 2 containers.
After this, you will only need to go to “You are almost done!” and fill the form with the right DB hostname.
Cheers,
m.
Bonus pack
I noticed a kind some confusion in docker concepts, so I hope you don’t mind if I clarify them here with some diagrams I made some time ago:
- Dockerfile: The instructions to build the image. [“The Recipe”]
- Image: The abstract container model. [“The Mould”]
- Container: The concretion of an abstract image. [“The Cookie”]
- Volume: The data, which can be persistent or volatile. [“The dish?”]
To be more specific, in our “ojs” dockerfile-recipe we add a tinny linux distribution (that is called “alpine”) with an Apache 2 web server and PHP 7.3… (well we have multiple dockerfiles and this is kind of variable, but let’s make is simple).
This Dockerfile is built to create an image. One single image that will be the mould for any future container you run.
And when you run this single image-mould you can create infinite “ojs” containers.
At this point you need to know that in docker everything is volatile unless you tell docker to keep it. This is why you need “volumes” that help with storage safe (ie: uploaded files, your database…).
So now you will ask… but we have 2 containers, don’t we? One for “ojs” and the other for “db”.
Who creates all this?
An important idea behind docker is making containers as simple as possible (there are many reasons why this is a good idea) and combine them to make it work. So in our case, we split OJS in two containers: one that include for the web server, the code and the uploads (called “ojs”) and other for the mariaDB database (called “db”).
To define how an “stack” of containers can work together is what docker-compose is for.
Let me recycle a picture I made some time ago (and please, instead of “omeka” read “ojs”):
So in the left we have our “docker-compose.yml” file that again is a kind of playbook that define your “stack” of applications. In our case, we like to run a “ojs” container (omeka-s in the picture) and a mariadb (the db).
Let’s say we have 2 folders… one called “production” and other called “development”. When you rise this “stack” (advice: docker don’t call it stack, but I think it’s a good name to illustrate) in your production folder, docker will create two containers and some volumes and your application will be alive.
Same will happen if you go to development folder… but you need to be careful if you run both in same server because it will usually collide trying to get same ports. You can define your variables as “ports” or the container names in the “.env” file you have (or you need to create) close to the docker-compose.yml.
If not for you… I hope this explanation will help future readers.
Cheers,
m.
Hello @marc,
Thanks again for your detailled answer. It is 100% clear and your english is perfect.
Sorry for the late reply, I was busy with other stuffs, but I will try to answer more early in the future.
After running the 2 folders as you described, I didn’t get any container, so what is shown on the picture still the same, only 2 containers. I don’t why.
After stopping everything, the 2 containers are gone.
Then, I tried, as you suggest, to replace “localhost” by “db” but I am still getting the same error
Is there some requirements that I’ve to install ? or I have to create a database before ?
Hello @marc,
Some update for you, maybe it will be useful.
I tried some solutions and the old error is gone but I have now this one:
A database error has occurred: Access denied for user ‘ojs’@‘172.18.0.3’ (using password: YES)
Any suggestions ?
Cheers,
Anouar
Hi @anouar2002
Sorry for the silence. In confidence, I run out of ideas about the former issue. How did you fix it?
It will probably help to understand why it fails.
About the new one, pwd need to be “ojsPwd” as is defined by default in docker-compose.yml or in the .env file…and checking the zip you sent, looks like you set this pwd to “ojs”.
Check this in your .env file, but I see this:
MYSQL_ROOT_PASSWORD=root
MYSQL_USER=ojs
MYSQL_PASSWORD=ojs
MYSQL_DATABASE=ojs
The one that OJS will use is MYSQL_PASSWORD.
Sorry to expose this data. Please, once we fix it, replace them with safer keys.
You can check what data is reading your docker running (pay attention to MYSQL_PASSWORD):
> docker-compose config
If this fails publish the output here… to dig it further.
Right now, if “ojs” pwd fails, the only thing I can imagine is related with Windows. I don’t use it and I never tested in this OS… but docker-compose.yml is using a lot of variables with “${variable:-defaultValue}” syntax, that works fine in bash/linux but I don’t know if this is really windows/powershell compliant.
If “docker-compose config” don’t return a well structured docker-compose, please replace all the variables in docker-compose.yml with static values to be sure docker get the right values.
The steps will be:
-
Create a copy of you working folder (if your docker-compose.yml is in “ojs-docker-master”, copy this folder to -for instance- “ojs-docker-master2”).
-
Go into this folder and edit “docker-compose.yml”.
-
With your favorite text editor, search all the variables and replace them with the value.
For instance (and specially) the line:
MYSQL_PASSWORD: "${MYSQL_PASSWORD:-ojsPwd}"
need to be replaced with:
MYSQL_PASSWORD: "ojsPwd"
-
Run the stack with the new values with “docker-compose up”.
-
Go to your browser and open localhost to open OJS installation form.
-
Fill it with the data we know now:
- Host: db
- database: ojs
- user: ojs
- pwd: ojs
(Uncheck the “create database” checkbox because docker will do it for you)
Please, let me know if this goes better this time.
Take care,
m.
Hello @marc ,
Thanks for the quick response.
No Problem To be honest, I don’t exactly how but I removed everything and I start the hole process again from the bottom but with “db” as host name and not “localhost”.
Yes, you are right ! This was the problem ! Replacing “ojsPwd” by “ojs” fix the problem and the error is gone. Otherweise, I am getting another one which is “The directory specified for uploaded files does not exist or is not writable.”
It is now a problem of permissions I think. This is the path of folder that I am using:
I think I respect all the rules and I check that the concerning folder exists and writable !
I don’t know where comes the error from ?
Cheers,
Anouar
To be honest, I don’t exactly how but I removed everything and I start the hole process again from the bottom but with “db” as host name and not “localhost”.
It make sense. There is no database in ojs container so moving from “localhost” to “db” could fix it.
Replacing “ojsPwd” by “ojs” fix the problem and the error is gone.
Hurray!! We are closer now.
I am getting another one “The directory specified for uploaded files does not exist or is not writable.”
When working with docker you need to think who is asking you about an error.
At the beginning could be confusing, but you will get the logic so fast.
Remember this: Think in containers as independent machines with the application you are running. This is the magic of docker… your application is independent of the host that runs docker, so you won’t never have conflicts with libraries, or a mess of logs, etc.
In this case, as you are running the installer, the “ojs” container is the one that is talking you you need to specify a path inside the container.
The container is a linux machine, so it won’t never be something as “C:/whatever” it will be “/whatever”.
And the right path depends on how you define the volumes… and if no volume is created, the default will be “/var/www/files”.
Checking the docker-compose.yml you sent, in the volumes of your “ojs” container looks like you are not using volumes so try with using the default path (/var/www/files).
I don’t know what are you going to do with project, but remember what I explained before about “persistency” in docker": by default, all stuff is volatile and will be “reset” on every run, so “volumes” are there to store all the data that you like to be persistent.
If you like to create a volume for your uploaded files, you need to go to docker-compose.yml and uncomment this line before you run your installation:
- ./volumes/private:/var/www/files
This is what is done by default in ojs docker-compose.yml for the database data… because I can’t imagine an scenario where you don’t want your database persistent.
So, summarizing:
- Try it without container, just setting your upload folder to “/var/www/files”.
- If i works, stop with “docker-compose stop” and uncomment docker-compose.yml to use a volume for private data (as explained before).
Cheers,
m.
Hello @marc,
After two weeks of trying, I am very happy to see this output:
Yes, you have right, this was the problem. I replace my path with (/var/www/files) and it works.
I will write some articles in order to test an integration with another framework and yes, a persistent database is mandatory ! So I will follow your instructions to do that.
Thanks again for the full and free support during this two weeks
Cheers,
Anouar
Great! You are officially the first windows user using OJS docker images.
Hope you don’t mind I changed your post title to make it easier to be found if somebody else falls in this in future.
Thinking in them, summarizing what we did is: when installing, be sure you…
- Use “db” as database hostname.
- Use “/var/www/files” as your upload folder.
- Check your “.env” file to know your db password (variable “MYSQL_PASSWORD”)
We will probably need to highlight this in the docker-ojs readme file.
About the images, as far as I test, you can use any OJS image except for the new 3.3 branch.
Something changed in this new release and I’m getting errors. I will inform you as soon as I fix it.
BTW, can you tell us more about your project?
Is something internal or do you think your work could be useful for others?