Virtual host URL of wordpress Docker CE container - docker

I'm very new about Docker CE.
I use Rocky Linux release 8.7 (Green Obsidian)
and Apache/2.4.37 .
I make wordpress Docker container.
Seems like I sucessfully build
using 'command docker-compose up -d' command
And I wonder What is this URL?
I already made 2 virtual host and certbot setting and it worked great.
I put wordpress directory here
/var/www/html/yw/wordpress
And this is my vertual host ROOT directory
/var/www/html/yw
The domain is below and I would like to display the WP page domain This URL .
www.foo.com
and I wrote docker-compose.yml like this
version: '2'
services:
db:
image: mysql:5.7
ports:
- "3307:3307"
volumes:
wordpress:
depends_on:
- db
image: wordpress:auth
ports:
- "81:80"
restart: always
working_dir: /var/www/html/yw/wordpress
volumes:
- /var/www/html/yw/wordpress:/var/www/html/yw/
environment:
however when I type www.foo.com
wordpress first page didn't show up. just Apache green page shor up.
Could someone correct my code please ?

Related

Docker-compose Apache mapping external local directory to document root

I am pretty beginner with Docker, and I'm trying to create a local development LAMP (more exactly Apache, MariaDB, PHP) stack using docker-compose, existing Docker images from Docker hub and no Dockerfile if possible, to be used with several local web projects.
I'd like to map my local web project directory /Users/myusername/projects/myprojectname to the default document root for Apache container (which seems to be /app for the Apache image I'm using)
Here is my docker-compose.yml file:
version: "3"
services:
mariadb:
image: mariadb:10.5
container_name: mariadb
restart: always
ports:
- 8889:3306
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER=localmysqluser
- MYSQL_PASSWORD=localmysqlpwd
php:
image: bitnami/php-fpm:7.4
container_name: php
ports:
- 9000:9000
volumes:
- /Users/myusername/projects/myprojectname:/app
apache:
image: bitnami/apache:latest
container_name: apache
restart: always
ports:
- 8080:80
volumes:
- ./apache-vhosts/myapp.conf:/vhosts/myapp.conf:ro
- /Users/myusername/projects/myprojectname:/app
depends_on:
- mariadb
- php
But when I do docker-compose up -d then browse to http://localhost:8080/, I get zero data. Where am I wrong? Is my docker-compose.yml configuration wrong, or is it because of system rights?
I've been looking at this similar question, but I'd prefer not using any Dockerfile if possible.
Further question: is it possible to make a local directory /Users/myusername/projects/ browsable by Apache in my local browser?
As answered by J. Song, exposed port number of this Apache Docker image is 8080, not 80.
So we just need to change port mapping of Apache service to 8080:8080 instead of 8080:80.

PhpStorm Docker remote PHP interpreter stops responding with message "Checking PHP Installation"

I'm trying to setup development environment using PhpStorm, Docker on Windows 10 machine.
When remote PHP interpreter selected PhpStorm stops responding with message "Checking PHP Installation":
docker-compose.yaml
version: '3'
networks:
symfony:
services:
#nginx
nginx-ea:
image: nginx:stable-alpine
container_name: nginx-ea
ports:
- "8081:80"
volumes:
- ./app:/var/www/project
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php74-fpm
- mysql8-ea
networks:
- symfony
# php74
php74-fpm:
build:
context: .
dockerfile: ./php/Dockerfile
container_name: php74-fpm
ports:
- "9001:9000"
volumes:
- ./app:/var/www/project
- ./php/conf:/usr/local/etc/php/
networks:
- symfony
php74-cli:
# define the directory where the build should happened,
# i.e. where the Dockerfile of the service is located
# all paths are relative to the location of docker-compose.yml
build:
context: ./php-cli
container_name: php74-cli
# reserve a tty - otherwise the container shuts down immediately
# corresponds to the "-i" flag
tty: true
# mount the app directory of the host to /var/www in the container
# corresponds to the "-v" option
volumes:
- ./app:/var/www/project
# connect to the network
# corresponds to the "--network" option
networks:
- symfony
# mysql 8
mysql8-ea:
image: mysql:8
container_name: mysql8-ea
ports:
- "4309:3306"
volumes:
- ./mysql:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
restart: always # always restart unless stopped manually
environment:
MYSQL_USER: root
MYSQL_ROOT_PASSWORD: secret
MYSQL_PASSWORD: secret
networks:
- symfony
#PhpMyAdmin
phpmyadmin-ea:
image: phpmyadmin/phpmyadmin:5.0.1
container_name: phpmyadmin-ea
restart: always
environment:
PMA_HOST: mysql8-ea
PMA_USER: root
PMA_PASSWORD: secret
ports:
- "8090:80"
networks:
- symfony
Docker Desktop Windows 10 settings
Have tried selecting both php74-fpm container and php74-cli container, as soon as settings applied in PhpStorm it stops responding completely.
Any idea what is wrong in here?
UPDATE
Including PHPStorm logs from system\log\idea.log
# appears in logs when Remote PHP Interpreter settings applied
2020-11-27 09:14:00,859 [ 479670] DEBUG - php.config.phpInfo.PhpInfoUtil - Loaded helper: /opt/.phpstorm_helpers/phpinfo.php
2020-11-27 09:14:01,106 [ 479917] INFO - .CloudSilentLoggingHandlerImpl - Creating container...
2020-11-27 09:14:02,019 [ 480830] INFO - .CloudSilentLoggingHandlerImpl - Creating container...
2 Docker containers are created after Remote PHP Interpreter settings applied however they don't seem to be activating and logs inside the container doesn't seem to say anything
if try starting "phpstorm_helpers_PS-191.8026.56" container manually from docker desktop it seems to start ok
if I manually try to start "festive_zhukovsky..." container it doesn't start.
logs inside container prints xml:
https://drive.google.com/file/d/1d5XbkJdHnc7vuN0V7heJdx3lBkmJfs3V/view?usp=sharing
UPDATE 2
if i remove local PHP version which comes from xampp package in PHPStorm the windows on the right shows where PHPStorm is hanging and become unresponsive:
UPDATE 3
according to this article https://ollyxar.com/blog/docker-phpstorm-windows
Docker should have Shared Drives configuration
however I don't seem to have this option in Docker Desktop Settings:
Can this be a problem?

Docker-volume of webroot not editable on host machine

I have a docker-compose LAMP stack comprised of three services; a webserver, php and mysql.
The apache2 webroot inside the container is shared to my local machine using a volume like so:
volumes:
- ./public_html:/usr/local/apache2/htdocs
When the stack is running though, I can't edit files inside of the shared volume, since I have a different local user as the user inside the apache2 container. Additionally the installer of my CMS (Processwire) is unable to acquire permissions to the required install directories.
The apache container uses alpine 2.4.35.
I've build my docker-compose file according to this tutorial:
https://medium.com/#thivi/creating-a-lamp-stack-using-docker-compose-13ca4e3950e1
Below I have attached my docker-compose.yml.
version: '3.7'
services:
apache:
build: './apache'
restart: always
ports:
- 80:80
- 443:443
networks:
- frontend
- backend
volumes:
- ./public_html:/usr/local/apache2/htdocs
- ./cert/:/usr/local/apache2/cert/
depends_on:
- php
- mysql
php:
build: './php'
restart: always
networks:
- backend
volumes:
- ./public_html:/usr/local/apache2/htdocs
- ./tmp:/usr/local/tmp
mysql:
build: './mysql'
restart: always
ports:
- 3306:3306
expose:
- 3306
networks:
- backend
volumes:
- ./database:/var/lib/mysql
networks:
backend:
frontend:
Is there any way to fix this issue? I'd be grateful for answers, I've been dealing with this issue for the past 2 days, without getting anywhere and I'm also kind of surprised that such an essential feature like directory sharing is so complicated.
/edit:
I've also noticed something interesting; when I execute a bash inside the apache-container the ownership of apache's document root is set to nobody:nobody, which probably also isn't right.

New to docker, Not seeing local changes made on site

I've been working on a site using laravel 5.8 which runs on a docker container and usually I've been able to save my local changes and the site on my local host reflects them but not my changes aren't seen on the site.
I'm running docker-compose up -d and it starts with the laravel driver, creating php and creating nginx but My local changes just won't show.
Should I be running a different command?
docker-compose file:
version: '3'
networks:
laravel:
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- "8080:80"
volumes:
- ./:/var/www
- ./resources/docker/nginx:/etc/nginx/conf.d
depends_on:
- php
networks:
- laravel
php:
image: quay.io/testRepo/docker-php-iaccess-odbc:7.3-devel
container_name: php
volumes:
- ./:/var/www
environment:
- PHP_OPACHE_ENABLE=0
ports:
- "9000:9000"
networks:
- laravel
docker-compose volume mounting requires either a full path or using the Version 3 bind configuration.
https://docs.docker.com/compose/compose-file/#volumes
In Linux/Unix OSes the pwd CLI command can be used as a short cut.

Docker compose linking to mariaDB

I’m trying to create a basic development machine running php7, nginx and mariaDB, using docker-compose.
The stripped down version of my compose file is as follows:
wwwroot:
container_name: wwwroot
image: wwwroot
volumes:
- .:/var/www
restart: always
nginx:
container_name: nginx
image: nginx
links:
- php70
volumes_from:
- wwwroot
ports:
- "80:80"
- "443:443"
restart: always
php70:
container_name: php70
image: kreable/php70
volumes_from:
- wwwroot
links:
- mariadb
restart: always
mariadb:
container_name: mariadb
image: mariadb
environment:
DB_ADMIN_PASS: pass
ports:
- "3306:3306"
restart: always
This works fine and creates the desired containers. The problem comes with trying to connect a basic PHP script to the database. I always get:
SQLSTATE[HY000] [2002] Connection refused
My PHP application is in the wwwroot container.
Do have I to do any further configuration to allow my PHP application to connect to the mariaDB container?
Thanks.
Looking at your code, you have setup a link from php70 to the mariadb container, but you don't have one in the wwwroot container. If you are trying to connect from your wwwroot container, then you will need to add a link to mariadb from there as well. Or it looks like you probably want to be connecting to your php70 container instead.
Also, it might be good to show the PHP code that you are using to try and connect to mariadb, that is causing the error.

Resources