Has anyone been successful with running OJS in a docker container?

Hello folks, Happy new year,

I am having some problems with running OJS locally or with docker. When I run OJS locally, I can’t install any plugins at all, plugins are uploaded but not installed and as a result the whole application becomes broken every time I install a plugin.

Every time this happens, I new to re-haul the application from scratch and it gets pretty frustrating.

As of the moment, I am just beginning to test whether OJS is the right choice for my use cases or not but I can’t do anything with it if I can’t setup an OJS site properly.

I have also looked into the following post for setting up docker:

I have been unsuccessful following forum’s advise. I have followed this guide for setting up OJS with docker-compose:
https://hub.docker.com/r/pkpofficial/ojs

I have been more successful running docker containers that comes pre-built with everything. An example is the following web app:
https://hub.docker.com/r/alextselegidis/easyappointments

The above guide for setting up EasyAppointments is very easy and doesn’t require much, is there something like this available for OJS?

1 Like

Hi @milanduke

Let me answer by parts:

Has anyone been successful with running OJS in a docker container?

In October alone, OJS images were pulled from dockerHub more than 5,000 times, so I sincerely hope that the answer to this question is “yes” or somewhere there are a lot of people in trouble… :wink:

imagen

How to deal with plugins?

Just to be sure I understood your exact problem.

You followed this installation process: https://github.com/pkp/docker-ojs

And after this, all works as expected (ojs up and running) but when you install a new plugin… the magic disappears.

When I run OJS locally, I can’t install any plugins at all, plugins are uploaded but not installed and as a result the whole application becomes broken every time I install a plugin.

Well, this is not a problem with docker or OJS images… the problem is that you are running the easyOJS commands without understanding what they entail.

The docker-compose.yml included in the easyOJS example is (intentionally) very basic and meant to run an OJS demo quickly and easily. But if someone wants to do more advanced usage than that (for example install new plugins), they should need to adapt that docker-compose to their needs.

Actually for your case, the adaptation is something simple as (although it does not explicitly mention the plugins) the problem you are facing is the same that is discussed in the documentation, in the “Special Volumes” section.

So, in short… You need to know that, when you install a new plugin, you are doing it inside a container that is “ephemeral” (it will return to its initial state every time you restart the container) but your DB is not ephemeral (because we like to keep it save and it’s stored on the host, outside the container), so when you reset your container, it creates an inconsistency between the code and the DB.

To make your plugins NOT ephemeral, the only thing you have to do is to give the directory “/var/www/html/plugins” persistence. Easiest solution is mapping it to a folder in your host (and make sure the plugins in the host folder are sync with the version of your OJS, of course).

Try this and if you have any problem, report it in this thread and I’ll give you a hand.

I have been more successful running docker containers that comes pre-built with everything. An example is the following web app: https://hub.docker.com/r/alextselegidis/easyappointments

Thanks for the reference. It’s a nice project, but don’t have the complexity we have in OJS so we can’t apply the same solutions.
Anyway, I will take a deeper look to see if we can do things better with our docker images.

Happy new year!

2 Likes

Hi marc,

Do you have any tutorial on creating a docker image for this OJS, not just a docker-compose setup but an image that contains everything.
I need to move this around between servers so I can’t setup in all servers separately, a docker image would make it easy for me to move it, reset it to its default state (if something breaks) or make copies.

Maybe you will find it useful - my docker-compose.yml file:

networks:
  inside:
    external: false

services:
  db:
    image: mariadb:10.2
    container_name: "ojs_app_34_db_latest"
    environment:
      MYSQL_ROOT_PASSWORD: "xxxxxx"
      MYSQL_DATABASE: "xxxxx"
      MYSQL_USER: "xxxxx"
      MYSQL_PASSWORD: "xxxxx"
    volumes:
      - ./volumes/db:/var/lib/mysql
      - ./volumes/dump:/docker-entrypoint-initdb.d
      - ./volumes/logs/db:/var/log/mysql

      networks:
      - inside
    restart: always

  ojs:
    image: "pkpofficial/ojs:latest"
    container_name: "ojs_app_34_latest"
    hostname: "xxxxx"
    ports:
      - "8340:80"
      - "8341:443"
    volumes:
      - /etc/localtime:/etc/localtime
      - ./volumes/private:/var/www/files
      - ./volumes/public:/var/www/html/public
      - ./volumes/apache-logs:/var/log/apache2
      - ./volumes/config/ojs.config.inc.php:/var/www/html/config.inc.php
      - ./volumes/plugins:/var/www/html/plugins

    networks:
      - inside
    depends_on:
      - db
    restart: always


  admin:
    image: adminer
    container_name: "ojs_app_34_latest_adminer"
    depends_on:
      - db
    ports:
      - 8088:8080
    networks:
      - inside
    restart: no
2 Likes

Thanks for sharing this Adam.

I had to setup a server to run OJS, I will try to create a docker container later today and share it here.

Linux or Windows as a host for docker?

Linux, Ubuntu Linux.

@milanduke - I just migrating from docker to proxmox container ubuntu 20.04 … hope this will be better

1 Like

I marked your answer as solution, I think your current setup is enough for anyone looking to setup OJS with Docker, I went ahead and set it up the old fashioned way with a server.

I need to move this around between servers so I can’t setup in all servers separately, a docker image would make it easy for me to move it, reset it to its default state (if something breaks) or make copies.

Without detracting from Adam’s proposal, which is undoubtedly effective, personally (and I insist that this is a personal opinion) I think that combining proxmox and docker is not THE solution to the problem.

I say this because I myself have strongly evaluated this combination (because proxmox offers some advantages over docker) but I came to the conclusion that virtualizing and then containerizing is over-engineering… because if you are already virtualizing, you don’t need to containerize and if you have containers, why add the overhead of virtualization?

If the problem you are trying to solve is the portability of journals from one server to another, I think a lighter and simpler solution is to create a script to move the containers and their volumes.

It could be a simple bash script, but today, my preference here would be to use ansible.

The script should just:

  1. Package the container and its volumes (if the container is stopped first, a simple tarball would do… although for elegance, a DB dump would be better).
  2. Move the package from one server to another.
  3. Extract the package on the target server and re-upload the journal.

The package should include the files (public&private) the DB, and the plugin volumes.
Notice that, if you choose to do a dump, the official mysql image includes an entrypoint that loads the dump automatically when starting the container.

Following this process, there is no need to add virtualization.

As there is no single way to do this (and the solution is not conected with the iniitial question), I will uncheck the “Solution” tip, just to show the discussion is still open.

Do you have any tutorial on creating a docker image for this OJS, not just a docker-compose setup but an image that contains everything.

A tutorial on how to create a docker image for OJS is beyond the scope of this forum and actually I think it would not make much sense as it misses the main benefit of the official docker images (created by ojs experts, tested by the community…).

However, if someone prefers to generate his own image, this is the current official image (based on alpine and assembling the code from git):
https://gitlab.com/pkp-org/docker/ojs/-/blob/main/templates/dockerFiles/Dockerfile-alpine-apache-php81.template?ref_type=heads

And this other the multi-stage version (and based on debian and downloading the code from the release tarball) towards which we will go someday:
https://github.com/marcbria/docker-pkp/blob/main/Dockerfile

Cheers,
m.

Yes - I agree - I just LEFT Docker and do a clean install on Proxmox Container (as in oridinal Linux Server)…

1 Like