After leaving it for a while, I decided to have another go at setting up dev environments with Docker.
I tried it with a web app I made for myself as an experiment.
One of the problems I have come across is that PHP doesn’t include the ZipArchive class.
I have already searched around the net for a solution, but nothing I have found works.
I assume it’s just a case of running the correct install command in the PHP.dockerfile
, but has anyone got an idea what is the correct command is to get ZipArchinve
working?
I’m using WSL2 (Ubuntu in Windows) and the latest PHP8.2.
php - Official Image | Docker Hub
“How to install more PHP extensions”
Check to see if it’s already there and just needs to be enabled, or if its not, it should be available through PECL as “zip”?
Funny thing, me to. I have been playing with Docker for the last several days after leaving it long ago.
This is what I did on Ubuntu 22
Dockerfile
FROM php:8.1-apache
RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli && docker-php-ext-install pdo pdo_mysql && docker-php-ext-enable pdo pdo_mysql
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y \
libzip-dev \
zip \
&& docker-php-ext-install zip
Result
And this is my docker-compose.yml
version: '3.8'
services:
php-apache-environment:
container_name: php-apache
build:
context: ./php
dockerfile: Dockerfile
depends_on:
- db
volumes:
- ./php/src:/var/www/html/
ports:
- 8000:80
db:
container_name: db
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: MYSQL_ROOT_PASSWORD
MYSQL_DATABASE: MYSQL_DATABASE
MYSQL_USER: MYSQL_USER
MYSQL_PASSWORD: MYSQL_PASSWORD
ports:
- "9906:3306"
phpmyadmin:
image: phpmyadmin/phpmyadmin
ports:
- '8080:80'
restart: always
environment:
PMA_HOST: db
depends_on:
- db
Project Structure
./mydocker
├── docker-compose.yml
└── php
├── Dockerfile
└── src
└── index.php
That last part of the docker file did it, thank you.
I did try it a while back, but gave up after it seemed I was banging my head against a wall, trying to get things to work.
I decided to give it another go. Still I’m hitting a few walls, but there is steady progress.
I have always used VMware Workstation and ran Virtual Machines. Docker is another whole layer of learning just to setup a local dev. I can see the value in being able to configure specific versions of the stack components but I always develop in current versions so it isn’t something I need for myself. And if I did need something specific, I can very easily create a new VM for it. I also tried Vagrant way back. The VM’s in workstation is the win for me personally.
Workstation is a paid product but you can always use the VMware player (non-commercial use) or Virtualbox, both of which are free.
I guess that will be another option to look at if I get fed up with Docker again.
As long as you are playing with containers, check out Devil Box. As the site says, it is a " Docker LAMP development stack with valid https support"
Another one to bookmark, looks interesting.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.