How to force new wordpress docker image? - php

How do I force docker-compose to update an image?
Given the recent exploits of php (e.g. MS-ISAC ADVISORY NUMBER: 2018-101), I want to update my docker-compose wordpress.
I tried:
docker-compose down && docker-compose build --pull && docker-compose up -d
When I check the version of php though, it lists 7.2.9 rather than 7.2.10
I check it by:
docker exec -it wordpress_wordpress_1 /bin/bash
php -v
I believe that it should list 7.2.10 because when i go to wordpress on docker hub and follow the link for latest, I see that it lists php:7.2-apache, and when I check php on docker hub for 7.2-apache, the Dockerfile lists 7.2.10 (see: L116)

It depends on whether the wordpress image available in docker hub was rebuilt since php was updated.
Your best bet is to rebuild the wordpress image yourself, instead of pulling it from wordpress using wordpress' dockerfile.

Instead of using latest, use the latest tag released. That would force compose to use that version of the image. Or you could also use the --no-cache flag when running docker-compose build to download the image again.

It turns out that even though the changes were merged, dockerhub was still showing that the most recent update was before the merge. (so dockerhub wasn't up to date yet)
https://github.com/docker-library/php#see-a-change-merged-here-that-doesnt-show-up-on-docker-hub-yet

Related

Run Wordpress with docker-compose without using the wordpress image

I would like to upgrade a very old wordpress installation. I would like to reproduce the live enviroment locally. For this, I would build my PHP, MySQL via docker compose. However, I have a problem with this. Normally you would take the ready wordpress images for this. But in my case I can't do that because the WP version is not supported in the docker hub or elsewhere. For this reason I would build my docker-compose with the following images: php7.0, apache and MySql. However, I am wondering how to include the PHP modules that wordpress needs in my yaml file. Is there a template I can follow? And is the way I choose here the right one or is there an alternative way?
Docker images are made out of layers. You can take a PHP image from Docker Hub and add onto it. In fact, the official Wordpress image uses the official PHP image as a base.
Create a new Dockerfile.
You can pick a PHP 7 variant as the starting base:
FROM php:7.0-apache
For some extensions, like GD Library (used for making thumbnails) you need to install some dependencies. This image is based on Debian Linux, so you use:
RUN apt-get -y update && apt-get -y install libfreetype6-dev libjpeg62-turbo-dev libpng-dev unzip
Next, you want some PHP extensions like the aforementioned GD Library and MYSQLi. In the official PHP image, there's a utility (see "How to install more PHP extensions") that makes it very simple:
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-install mysqli gd exif zip
Now you can build your image:
docker build -t mycustomphpimage:latest .
And run it:
docker run mycustomphpimage:latest
Building the image automatically with CI/CD in Gitlab/Github and deploying custom images to a repository to pull on a server is out of scope for this answer.
You could just build the image on the server itself when deploying. If you don't want to do that, you can also build the image locally and use docker export & docker import.
The Wordpress image for Wordpress installs some extensions, the most critical of these are gd, exif (images), zip (unpacking plugins), mysqli (database). Try to find out what your current production server has installed & add those to the Dockerfile—many will "just work" with docker-php-ext-install and some might be ignorable.
It might also be possible to use an old version of the Wordpress 5.0 image or to use it as a base (FROM wordpress:5-php7.0-apache).
You mentioned that you'd like to do this to upgrade an old install, so the following is not applicable to you, but for the sake of anyone that finds this answer in the future: just because you can run old PHP / Wordpress versions, please don't do that in production and try to upgrade as soon as you can.

Export Server not configured for Highcharts-export-server

I'm using highcharts-export-server to save images of the charts and attached results when generating PDF. It was working before but now it seems to be broken. I tried to update the node.js and version of npm that I am using and it keeps giving me an error "Export Server not configured." I run node buid.js and install globally the highcharts-expert server but it still gives me the same error.
Package install:
Node - 14.6.0
NPM - 7.6.3
Highcharts-export-server - 2.1.0
Check if you have the highcharts-export-server installed globally (you can do it with the npm list -g -depth 0 highcharts-export-server) and if you have, uninstall it (npm uninstall -g highcharts-export-server). After that, try to run the following command: highcharts-export-server --nologo 1 --logLevel 4 --infile ./basic.json --outfile ./chart.png --type png --width 500 and if it fails ('highcharts-export-server' is not recognized), try this one: npx ./node_modules/highcharts-export-server/bin/cli.js --nologo 1 --logLevel 4 --infile ./basic.json --outfile ./chart.png --type png --width 500. Please provide here the final results (attach the generated PNG).
In my case, I figure out that this issue was caused by wrong input at the step to confirm the CND.
At the CDN step, just press ENTER instead of input 'Y'. Then all the dependencies will pull from the CDN.
Run the node program, the image will be generated correctly.
Configure the package by running command line as follows at nodejs project root
node node_modules/highcharts-export-server/build.js
I recommend first, export this two environment variable, export ACCEPT_HIGHCHARTS_LICENSE=1 and export HIGHCHARTS_VERSION=9.0, them run npm install.

How can I add helper scripts docker-php-ext-configure, docker-php-ext-install in my docker image

I got detail about some helper scripts but I do not know how to add the support of these scripts in docker file. When I try to use the scripts
Scripts like: docker-php-ext-configure, docker-php-ext-install, and docker-php-ext-enable to more easily install PHP extensions.
I am getting errors like: /bin/sh: 1: docker-php-ext-configure: not found
I am using
FROM debian:stretch
for build docker container in my docker file.
Same helper scripts are working perfectly fine inn different images like:
FROM php:7.1-apache
FROM php:7.2-apache
If we build Docker file with these images.
php:7.X-apache image is already pre-built with all those scripts included as can be seen here: https://github.com/docker-library/php/tree/master/7.2/stretch/apache
If you need PHP 7.1 image/files you can try to search repository for last version of 7.1 image before it was deprecated.
All of those scripts can be found in this repo:
https://github.com/docker-library/php
Just RUN the scripts within your project directory via Dockerfile, or COPY over to the /usr/bin folder then RUN as you would any other bin script. Just keep in mind those scripts assume an Alpine-esque directory structure so if you're using something like Debian/Ubuntu it may not work out of the box.

PHP installation appears to be missing the MySQL extension which is required by WordPress?

I am currently updating our docker image in Azure.From this image appsvcorg/alpine-php-mysql:0.3 to this leonzhang77/alpine-php-mysql:0.31.
After pasting and save it on container,restart app, when I browse my site (linux.rapidvisa.com , Wordpress 4.9.7,PHP7) that error appeared.MySQL also cannot connect to var/run/mysqld/mysqld.sock.
I tried to fix it. I can see on my phpinfo.php that MySQL/MySQLi is not there or not running.
I am new in this Docker and Azure environment although I managed to enter into SSH and do some tweaking but no luck.
I tried to type sudo apt-get install blah..but command not found.Whenever I typed major commands always -ash: command not found. Can somebody advise me what to do?
i dont know what the exact problem is with your docker construct but your second one is the alpine distribution.
in alpine linux there is an other package manager system.
you have to use apk.
like: apk update or apk add htop

Add Image to my Base Docker Image

I have a docker base image that runs CentOS 6.5. This image is saved on my computer. I could not find anything that talks about how to add more images into this base image. So for example I have this base image of CentOS6.5, I need too add postgresql 9.3, and php too this base image. Is there a way once you already have a base image made, to add more packages too that base image?
That's the whole purpose of the Docker file : build something on top of an image.
Create your dockerfile
Build the new image and tag it with docker build -t <tag> <path/to/build/context>
Then if you want to share it, push it to your private registry or to the docker hub to make it world accessible (docker push <tag>).
The build context of step 2 is the parent directory of your Dockerfile. For instance if you run the command in the directory where your dockerfile is it would be docker build -t <tag> ..
You can use Dockerfiles and docker build to do this e.g.:
FROM yourCentos
MAINTAINER your name
RUN yum install ...
CMD ...
And then docker build -t="myImage" . in the direcotry where you created the dockerfile.
Or you can upgrade youe images via CLI (not the preferd way!!) and commit them.

Categories