Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connecting to mysql within compose #4

Open
ScreamingDev opened this issue Apr 8, 2017 · 0 comments
Open

Connecting to mysql within compose #4

ScreamingDev opened this issue Apr 8, 2017 · 0 comments

Comments

@ScreamingDev
Copy link

ScreamingDev commented Apr 8, 2017

Connecting to some other server shouldn't fail but actually it does.
Can you please bring in the hostname resolv via the docker network?

I guess this is the problem here because dockers php:5.6 is able to connect to some other container.
With your container I need to add a "links: mysql" in the docker-compose config. Dunno why.

version: '3'

services:
  php:
    build: .
    ports:
      - "8000:80"
    volumes:
      - ".:/var/www/html"
  mysql:
    image: mysql:5.7
    environment:
      - MYSQL_USER=foo
      - MYSQL_PASSWORD=foo
      - MYSQL_DATABASE=foo
      - MYSQL_ROOT_PASSWORD=
      - MYSQL_ALLOW_EMPTY_PASSWORD=true

Dockerfile

FROM alterway/php:5.4-apache

RUN apt-get update

RUN apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

RUN docker-php-ext-install mysql


# Simple tasks at last
RUN apt install -y mysql-client

# Config
RUN a2enmod rewrite

config

define('DB_NAME', 'foo');
define('DB_USER', 'foo');
define('DB_PASSWORD', 'foo');
define('DB_HOST', 'mysql');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant