I have the following docker-compose:
version: "2"
services:
webserver:
image: orsolin/docker-php-5.3-apache
environment:
ALLOW_OVERRIDE: "true"
HTTP_PROXY: "${HTTP_PROXY}"
HTTPS_PROXY: "${HTTPS_PROXY}"
NO_PROXY: "${NO_PROXY}"
ports:
- "8000:80"
depends_on:
- db
volumes:
- ./app:/var/www/html/
db:
image: centos/mariadb-102-centos7
restart: always
volumes:
- ./mysql:/var/lib/mysql/:rw
environment:
MYSQL_ROOT_PASSWORD: *redacted*
MYSQL_USER: *redacted*
MYSQL_PASSWORD: *redacted*
MYSQL_DATABASE: *redacted*
HTTP_PROXY: "${HTTP_PROXY}"
HTTPS_PROXY: "${HTTPS_PROXY}"
NO_PROXY: "${NO_PROXY}"
ports:
- "8889:3306"
adminer:
image: adminer
restart: always
environment:
ADMINER_DEFAULT_DB_DRIVER: mysql
ADMINER_DEFAULT_DB_HOST: mariadb
ADMINER_DEFAULT_DB_NAME: adminer
ADMINER_DESIGN: nette
ADMINER_PLUGINS: tables-filter tinymce
HTTP_PROXY: "${HTTP_PROXY}"
HTTPS_PROXY: "${HTTPS_PROXY}"
NO_PROXY: "${NO_PROXY}"
ports:
- "8282:8080"
After I run docker-compose up -d, the container keeps on restarting and I can see the following when running docker logs --tail 50 --follow --timestamps 01e2489d4526
2019-07-11T10:03:45.554517000Z 2019-07-11 10:03:45 140548938721472 [Note] Plugin 'FEEDBACK' is disabled.
2019-07-11T10:03:45.559329000Z 2019-07-11 10:03:45 140548938721472 [Note] Server socket created on IP: '::'.
2019-07-11T10:03:45.559835000Z 2019-07-11 10:03:45 140548938721472 [ERROR] Can't start server : Bind on unix socket: Permission denied
2019-07-11T10:03:45.560319000Z 2019-07-11 10:03:45 140548938721472 [ERROR] Do you already have another mysqld server running on socket: /var/lib/mysql/mysql.sock ?
2019-07-11T10:03:45.560796000Z 2019-07-11 10:03:45 140548938721472 [ERROR] Aborting
And this is the docker ps
output:CONTAINER ID IMAGE
COMMAND CREATED STATUS PORTS NAMES
8d7e8d571a1b orsolin/docker-php-5.3-apache "apache2-foreground" 7 minutes ago Up 7 minutes 0.0.0.0:8000->80/tcp docker_webserver_1
5f0b1bb872c7 adminer "entrypoint.sh doc..." 7 minutes ago Up 7 minutes 0.0.0.0:8282->8080/tcp docker_adminer_1
01e2489d4526 centos/mariadb-102-centos7 "container-entrypo..." 7 minutes ago Restarting (1) 2 minutes ago docker_db_1
How would I fix this, keeping in mind that I will need to be able to connect to the mariadb container from the other containers as well?
Thanks
Best Answer
When SELinux is enabled, your containers' volumes should be placed in subdirectories of
/var/lib/docker/volumes
. Volumes in your home directory will have SELinux contexts that do not allow Docker containers to access them.