Docker-compose lab quiz 5

Hi All,

While taking quiz for Docker compose on question no. 5, I failed.

Here’s my docker-compose.yml file when I’m trying to add a link between wordpress web app with postgres db.

$ cat docker-compose.yml
version: “2.2”

services:
db:
image: postgres
environment:
- POSTGRES_PASSWORD=mysecretpassword
wordpress:
image: wordpress
ports:
- 8085:80
depends_on:
- db

On executing “docker-compose up”
:ballot_box_with_check: Sytax Check for the docker-compose.yml
:ballot_box_with_check: Wordpress running on the correct host port?
:x: Wordpress linked to db container ?
:ballot_box_with_check: db container running with env variable POSTGRES_PASSWORD?

But when I modified my docker-compose.yml as below :
$ cat docker-compose.yml
version: “2.2”

services:
db:
image: postgres
container_name: db
environment:
- POSTGRES_PASSWORD=mysecretpassword
wordpress:
image: wordpress
container_name: wordpress
ports:
- 8085:80
depends_on:
- db

Then,

:ballot_box_with_check: Sytax Check for the docker-compose.yml
:x: Wordpress running on the correct host port?
:x: Wordpress linked to db container ?
:x: db container running with env variable POSTGRES_PASSWORD?

There are spaces added inside my yml file, here the spaces are missing please ignore for the syntax.

Where did I go wrong please suggest.

Thank you!

Hi @Jethan

Kindly check the correct code below and try again:

services:
 db:
   environment:
     POSTGRES_PASSWORD: mysecretpassword
   image: postgres
 wordpress:
   image: wordpress
   links:
   - db
   ports:
   - 8085:80
version: '3.0'

Also, check my try below:

Sometimes the correct answer is located under path /var/answers/ as you can find the above answer inside it.

We do sorry for any inconvenience.

I hope this helps!

Thank you! :+1: :+1: :+1:

1 Like

I’m getting the same error as the first one above… tried your text verbatim and still getting a x where it says “wordpress linked to db container”… I have exactly your text above as in the solution.

You have to use links instead of depends_on.

@KodeKloud,

Even when running the answer file / example, it does not seem to be creating the link to the db container. I do not see the entry for the db container, when printing the contents of /etc/hosts on the wordpress container.

@KodeKloud @kodekloud-support3

Kindly check this twice. I can confirm that there is an issue with this lab.

After many tries, I copied the file in /var/answer… to docker-compose.yml and tested with the same result.


Thank you

@KodeKloud @kodekloud-support3 I have the same issue. I even pasted exactly the same yaml file and it still says it was not connected.