Im trying to build wordpress theme with docker & docker-compose. The problem that Im having is that Im trying to copy my theme into exposed wp-content folder of docker but for some reason it says there is not such file or directory.
Runing ls command my folder structure looks like this:
wp-content // available only after docker compose finishes
theme
dockerFile
docker-compose.yaml
Here is how my docker-compose.yaml file looks like
version: '3'
services:
# Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
networks:
- wpsite
# phpmyadmin
phpmyadmin:
depends_on:
- db
image: phpmyadmin/phpmyadmin
restart: always
ports:
- '8080:80'
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
networks:
- wpsite
# Wordpress
wordpress:
build: .
depends_on:
- db
ports:
- '8000:80'
restart: always
volumes:
- ./wp-content/:/var/www/html/wp-content
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
networks:
- wpsite
networks:
wpsite:
volumes:
db_data:
And here how my DockerFile looks like
FROM wordpress:latest
RUN echo "Install wordpress"
COPY ./giveaway_theme ./wp-content/themes
RUN echo "Copy theme to wp-content folder"
Looks like im somehow inside container, because when I run ls command it shows nothing, So my question is is there any way that I can copy theme into wp-content folder after docker compose finishes ??
In your Docker file you are not setting a WORKDIR, hence your COPY command is relative to root (/). So it copies your theme to /wp-content/themes.
Before the COPY command you can set:
WORKDIR /var/www/html
This would fix your Dockerfile. And you will ship the image with the theme already inside.
You are already mapping a local copy of wp-content into the a volume. So if you just place your theme in the correct location on your host (inside ./wp-content/themes) then it will be picked up by docker-compose. At that point you don't need the COPY command in the Dockerfile anymore.
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.