I am coming from here:
How to run docker-compose with host network?
the problem I realized is that mysql_connect
uses sockets when localhost
is entered as host. As a result, php on my host system, cannot find the socket because that socket is in the container.
when I up with compose-docker
I can read this
Version: '5.6.44' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
so what I thought I logically do, is to enter on my host, the mysql_connect socket configuration in php, to point to /var/run/mysqld/mysqld.sock
but that is in my container, so it cannot find it.
as a result, I tried mapping the container dir /var/run/mysqld
to some host dir, so I can then use that host socket directory in my php.ini on my host.
But:
when I start up I get:
Can't start server : Bind on unix socket: Permission denied
Do you already have another mysqld server running on socket
so mapping the socket folder somehow gives read write problems to the docker container. Is there any solution to this?
my yml file is this:
version: '3.3'
services:
sciodb:
container_name: sciodb
image: mysql:5.6
restart: always
environment:
MYSQL_DATABASE: 'db'
# So you don't have to use root, but you can if you like
MYSQL_USER: 'myuser'
# You can use whatever password you like
MYSQL_PASSWORD: 'test1234'
# Password for root access
MYSQL_ROOT_PASSWORD: 'test1234'
ports:
# <Port exposed> : < MySQL Port running inside container>
- '3306:3306'
expose:
# Opens port 3306 on the container
- '3306'
# Where our data will be persisted
volumes:
- /home/myuser/nmyapp_db:/var/lib/mysql
- /media/sf_vmwareshare:/var/vmwareshare
- /home/myuser/nmyapp_socket:/var/run/mysqld