Reputation: 6560
I've been using this Docker-Compose Repository for Wordpress plugin/theme development with phpunit and wp-cli.
Now I need to have soap in the Wordpress container so am trying to modify it to use my own Dockerfile.
When I build from an image
reference in the docker-compose
file, the Wordpress container stays up:
Name Command State Ports
----------------------------------------------------------------------------
mz-docker-dev_mysql_1 docker-entrypoint.sh mysqld Up 3306/tcp
mz-docker-dev_wordpress_1 docker-entrypoint.sh apach ... Up 80/tcp
But when I use my Dockerfile
, it exits:
Name Command State Ports
----------------------------------------------------------------------------
mz-docker-dev_mysql_1 docker-entrypoint.sh mysqld Up 3306/tcp
mz-docker-dev_wordpress_1 docker-php-entrypoint php -a Exit 0
Here's a minimal version of the docker-compose.yml
and my Dockerfile
.
version: "3"
services:
wordpress:
build: .
environment:
VIRTUAL_HOST: "${DOCKER_DEV_DOMAIN:-project.test}"
WORDPRESS_DB_HOST: "mysql"
WORDPRESS_DB_NAME: "wordpress"
WORDPRESS_DB_PASSWORD: ""
WORDPRESS_DB_USER: "root"
depends_on:
- "mysql"
networks:
- "front"
- "back"
volumes:
- "wp:/var/www/html:rw"
- "./mz-plugin:/var/www/html/wp-content/plugins/mz-plugin:ro"
mysql:
image: "mariadb:10.2"
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
MYSQL_DATABASE: "wordpress"
MYSQL_ROOT_PASSWORD: ""
networks:
- "back"
volumes:
- "./data:/var/lib/mysql"
networks:
front: {}
back: {}
volumes:
wp: {}
The Dockerfile:
FROM "wordpress:${WP_VERSION:-latest}"
FROM php:7.3
RUN apt-get update -y \
&& apt-get install -y \
libxml2-dev \
vim \
&& apt-get clean -y \
&& docker-php-ext-install soap \
&& docker-php-ext-enable soap
And I run in detached mode: docker-compose up -d
.
Am I missing a step when I build from the Dockerfile? Is there a configuration missing?
Thanks.
Upvotes: 1
Views: 174
Reputation: 31584
You may need to have a detail look for multi-stage build.
With multi-stage builds, you use multiple FROM statements in your Dockerfile. Each FROM instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don’t want in the final image. To show how this works, let’s adapt the Dockerfile from the previous section to use multi-stage builds.
Above means, unless you explicitly copy things from previous stage to next stage, the items in previous stage won't be seen in next stage. For you, when you define the FROM php:7.3
, this means your final image will be based on php:7.3
, has non business with wordpress
.
For next you got:
mz-docker-dev_wordpress_1 docker-php-entrypoint php -a Exit 0
This is because the php:7.3
's entrypoint is "docker-php-entrypoint"
, the container will exit directly after run the entrypoint if no foreground process there.
So, for you, just remove FROM php:7.3
, base on wordpress
image to do your customized works is the solution.
Upvotes: 1