0

I'm trying to configure a simple LAMP app.

Here is my Dockerfile

FROM ubuntu
# ...
RUN apt-get update
RUN apt-get -yq install apache2
# ...
WORKDIR /data

And my docker-compose.yml

db:
    image: mysql
web:
    build: .
    ports:
        - 80:80
    volumes:
        - .:/data
    links:
        - db
    command: /data/run.sh

After docker-compose build & up I was expecting to find db added to my /etc/hosts (into the web container), but it's not there.

How can this be explained ? What am I doing wrong ?


Note1: At up time, I see only Attaching to myapp_web_1, shouldn't I see also myapp_db_1 ? Note2: I'm using boot2docker

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307

1 Answers1

0

Following @Alexandru_Rosianu's comment, I checked

$ docker-compose logs db

error: database is uninitialized and MYSQL_ROOT_PASSWORD not set  
   Did you forget to add -e MYSQL_ROOT_PASSWORD=... ?

Since I now set the variable MYSQL_ROOT_PASSWORD

$ docker-compose up

Attaching to myapp_db_1, myapp_web_1
db_1  | Running mysql_install_db
db_1  | ...

I can see the whole db log and the db host effectively set in web's /etc/hosts

Community
  • 1
  • 1
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307