Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker mysql wordpress port doesn't connect

I downloaded the mysql and wordpress images. Mysql ports are

3306 localhost:32781 33060 localhost:32780

Wordpress configuration is

WORDPRESS_DB_HOST 192.168.99.100:32774

MYSQL_ROOT_PASSWORD and WORDPRESS_DB_PASSWORD are the same

I try to connect to wordpress with

http://192.168.99.100:32774/

I get the message

This site can’t be reached

How do I have to configure the ports of mysql and wordpress?

CONFIGURATION MYSQL

enter image description here

enter image description here

WORDPRESS

enter image description here

enter image description here

Error trace

enter image description here

like image 747
Carlota Avatar asked Nov 06 '22 17:11

Carlota


1 Answers

From what you can find on the docker configuration page, you should take this example and modify it to your needs. There is the following docker-compose file that will launch a wordpress in a minute: https://docs.docker.com/compose/wordpress/

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

From that file you have various options like, using docker compose tool (https://docs.docker.com/compose), or if you have a swarm running you could use docker stack command(https://vsupalov.com/difference-docker-compose-and-docker-stack/) or you can divide the configuration of both elements and create separate Dockerfile's(the configuration of a Docker file differs from what you can see on docker-compose so take the information an create your own) and launch them separated, you should launch mysql first as wordpress depends on a bbdd running first.

like image 94
Colin Moreno Burgess Avatar answered Nov 12 '22 10:11

Colin Moreno Burgess