简体   繁体   中英

How to enable Memcache in php:5.6-fpm-alpine docker container

This is error output on php -m

Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/memcache.so'

  • Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20131226/memcache.so: No such file or directory in Unknown on line 0

Dockerfile

ARG PHP_VERSION=5.6

FROM php:${PHP_VERSION}-fpm-alpine

RUN apk --update add openssh-client make grep autoconf gcc libc-dev zlib-dev

RUN cd /tmp \
    && curl -o php-memcache.tgz http://pecl.php.net/get/memcache-3.0.8.tgz \
    && tar -xzvf php-memcache.tgz \
    && cd memcache-3.0.8 \
    && curl -o memcache-faulty-inline.patch http://git.alpinelinux.org/cgit/aports/plain/main/php5-memcache/memcache-faulty-inline.patch?h=3.4-stable \
    && patch -p1 -i memcache-faulty-inline.patch \
    && phpize \
    && ./configure --prefix=/usr \
    && make INSTALL_ROOT=/ install \
    && install -d ./etc/php/conf.d \
    && echo "extension=memcache.so" > /usr/local/etc/php/conf.d/docker-php-ext-memcache.ini

docker-compose up -d has no error on execution, the extension is enabled but still missing from the system.

NOTE : This is a legacy system working on PHP 5.6 that needs to be dockerized in order to refactor the project to work on PHP 7.x

Project are dependant on Memcache and not on Memcached

The problem was the docker Memcached container, I tried to connect to the Memcached server using memcache.

I was unable to find the Memcache docker container so Memcached is used.

version: '3.6'

services:
   https://hub.docker.com/_/php/
  php-platform:
    environment:
      - PHP_IDE_CONFIG=serverName=localhost
    container_name: php-5.6
    build:
      context: .
      dockerfile: docker/php/5.6/Dockerfile
      cache_from:
        - ./docker/php/5.6/
    depends_on:
      - db
    links:
      - memcached-client
      - gearman
      - rabbitmq
      - mailcatcher
    volumes:
      - .:/var/www/dev-docker:rw,cached
      - /usr/local/lib
    extra_hosts:
      - dev-docker.geschenkparadies.ch:host-gateway
    networks:
      - default

  # https://hub.docker.com/_/node/
  nodejs:
    container_name: nodejs
    build:
      context: ./ReactAdmin
      dockerfile: ../docker/nodejs/Dockerfile
      cache_from:
        - ../docker/nodejs
    volumes:
      - ./ReactAdmin:/var/www/dev-docker/ReactAdmin:rw,cached
    networks:
      - default

  # https://hub.docker.com/_/nginx/
  web-server:
    container_name: nginx
    build:
      context: .
      dockerfile: docker/nginx/Dockerfile
      cache_from:
        - ./docker/nginx
    depends_on:
      - php-platform
    volumes:
      - .:/var/www/dev-docker:ro
    ports:
      - "80:80"
      - "443:443"
    expose:
      - "8000"
    networks:
      - default

  # https://hub.docker.com/_/mysql
  db:
    container_name: database
    image: mysql:8
    command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8 --collation-server=utf8_unicode_ci --max-allowed-packet=67108864
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=!ChangeMe!
      - MYSQL_DATABASE=gp_core
      - MYSQL_USER=gp_sql_local
      - MYSQL_PASSWORD=!ChangeMe!
      - MYSQL_TCP_PORT=3307
    volumes:
      - db-data:/var/lib/mysql
    ports:
      - "3307:3307"
    networks:
      - default

  # https://hub.docker.com/_/memcached
  memcached-client:
    image: memcached:alpine
    container_name: memcached-client
    command: -p 11212
    ports:
      - "11212:11212"
    networks:
      - default

 # http://localhost:15672/#
  rabbitmq:
    container_name: rabitmq-platform
    build:
      context: .
      dockerfile: docker/rabitmq/Dockerfile
      cache_from:
        - ./docker/rabitmq
    environment:
      - RABBITMQ_DEFAULT_USER=admin
      - RABBITMQ_DEFAULT_PASS=admin
    ports:
      - "5672:5672"
      - "15672:15672"
    networks:
      - default

  gearman:
    image: artefactual/gearmand:latest
    container_name: gearman-platform
    ports:
      - "4730:4730"
    networks:
      - default

  # https://hub.docker.com/r/schickling/mailcatcher/
  mailcatcher:
    image: schickling/mailcatcher
    container_name: mailcatcher
    ports:
      - "1026:1025" # changed to 1026 to avoid local instance of mailcatcher
      - "1081:1080"

networks:
  default:
    name: "network"

volumes:
  db-data: { }
  esdata1:
    driver: local

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM