I'm not able to connect to a db container with fpm-alpine image. Do I miss something or is it not possible with this image?
Bellow is my full configuration:
docker-compose.yml:
docker-mysql:
image: mariadb:latest
container_name: docker-mysql
environment:
- MYSQL_ROOT_PASSWORD=123123
- MYSQL_DATABASE=test-db
- MYSQL_USER=user
- MYSQL_PASSWORD=pass
docker-php-fpm:
build: .
dockerfile: docker/php-fpm/Dockerfile
container_name: neos-docker-php-fpm
volumes:
- ./:/var/www/app
links:
- docker-mysql
docker/php-fpm/Dockerfile:
FROM php:fpm-alpine
RUN apk add --update freetype-dev libpng-dev libjpeg-turbo-dev libxml2-dev autoconf g++ imagemagick-dev libtool make \
&& docker-php-ext-configure gd \
--with-gd \
--with-freetype-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install gd mbstring tokenizer pdo pdo_mysql imap opcache \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& apk del autoconf g++ libtool make \
&& rm -rf /tmp/* /var/cache/apk/*
WORKDIR "/var/www/app"
When I try to ssh into container
~ docker exec -it docker-php-fpm /bin/ash
and test the connection to db I get
/var/www/neos-docker # php -r "new PDO('mysql:host=localhost;port=3306;charset=utf8', 'root', '123123');"
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in Command line code:1
Stack trace:
#0 Command line code(1): PDO->__construct('mysql:host=loca...', 'root', '123123')
#1 {main}
thrown in Command line code on line 1
I'm not able to connect to a db container with fpm-alpine image. Do I miss something or is it not possible with this image?
Bellow is my full configuration:
docker-compose.yml:
docker/php-fpm/Dockerfile:
When I try to ssh into container
and test the connection to db I get