db
network_mode: bridge
ports:
- â8085:80â
volumes:
./root/wordpress
$
$
$ docker-compose config
ERROR: The Compose file â./docker-compose.ymlâ is invalid because:
services.db.environment contains {âPOSTGRES_PASSWORDâ: âmysecretpasswordâ}, which is an invalid type, it should be a string
$
$ docker-compose up docker-compose.yml
ERROR: The Compose file â./docker-compose.ymlâ is invalid because:
services.db.environment contains {âPOSTGRES_PASSWORDâ: âmysecretpasswordâ}, which is an invalid type, it should be a string
$
$
$
$ vim docker-compose.yml
$
$ vim docker-compose.yml
$
$ docker-compose config
services:
db:
environment:
POSTGRES_PASSWORD:mysecretpassword: null
image: postgres
network_mode: bridge
wordpress:
image: wordpress
links:
- db
network_mode: bridge
ports:
- 8085:80/tcp
volumes:
- root/wordpress
version: â2.1â
$
$ docker-compose up docker-compose.yml
ERROR: No such service: docker-compose.yml
$ pwd
/root/wordpress
$ ls -al
total 12
drwxr-xr-x 2 root root 4096 May 14 08:19 .
drwx------ 5 root root 4096 May 14 08:19 âŚ
-rw-râr-- 1 root root 265 May 14 08:19 docker-compose.yml
$ vim docker-compose.yml
$
$
$ docker-compose up docker-compose.yml
ERROR: No such service: docker-compose.yml
$
$ cat docker-compose.yml
version: â2.1â
services:
db:
environment:
- âPOSTGRES_PASSWORD:mysecretpasswordâ. # Adding quotes to see whether this can fix
image: postgres
network_mode: bridge
wordpress:
image: wordpress
links:
db
network_mode: bridge
ports:
- â8085:80â
volumes:
can i knew what is the actual task is ?
in Docker-compose we donât need to describe network because it creates automatically default network for those services. If in task it is described to create a new network then you can create.
Docker for beginners course
Module : Docker Compose Lab 4
Lab 1
First create a postgress database container called db , image postgres , environmental variable POSTGRES_PASSWORD=mysecretpassword
Lab 2
Next letâs create a simple wordpress container called wordpress , image: wordpress , link it to the container db and expose it on host port 8085
Lab 3
Now that we have a working wordpress site, lets run it with Docker Compose!
Letâs clean up the actions carried out in previous steps. Delete the db and wordpress containers.
Lab 4
Create a docker-compose.yml file under the path /root/wordpress . Once done, run a docker-compose up.
The compose file should have exact specification of the wordpress and db container
All of below checks fails and hence I have uploaded by script in above outputs.Though my script passes through yamllint.com website checks
Syntax Check for the docker-compose.yml
Wordpress running on the correct HostPort?
WordPress linked to db container
db container running with env variable POSTGRES_PASSWORD?
I used this script and tried resolving as much as I could to reach a point where docker-compose config command does not throw any more errors .
Few things in scripts provided docker-config did not accepted while parsing such as " " given to port numbers , version number 2.2 , array for links and ports . Only after removing those script was not accepted by docker-compose config for any errors.
Now docker-compose config does not gives any error for this modified script
But docker-compose up docker-compose.yml still gives error as No such service : docker-compose.yml
I have provided all outputs below such as error logs , pwd , ls -al etc
$
$ docker-compose up docker-compose.yml
ERROR: No such service: docker-compose.yml
$
$ docker logs db_container
Error: No such container: db_container
$
Can you please bring this to notice of our trainer Mumshad to guide us ?
This is the only lab we have for beginners in Docker compose and it is not working .
It shatters my confidence in whatever I have learnt in Docker and Yaml so far.
This is so basic and minimal configurations I am not sure how can I be move forward with Docker Swarm or advanced modules !!
wordpress:
links:
- db
image: wordpress:latest
ports:
- â8085:80â
$
$ docker-compose up
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in â./docker-compose.ymlâ, line 6, column 25
$
$ pwd
/root/wordpress
$
I tried fixing each and every error thrown by the terminal but it did not worked for me .
Every time you notice vi below is I have tried to fix each error I received .
I thought I was fixing errors in line 6 and line 13 in every vi command below.
I have even used YAMLLINT validator which resulted in all green but did not worked when docker-compose up was tried.
wordpress:
links:
- db
image: wordpress:latest
ports:
- â8085:80â
$
$
$ docker-compose up
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in â./docker-compose.ymlâ, line 6, column 24
$ vi docker-compose.yml
$
$
$ docker-compose up
ERROR: The Compose file â./docker-compose.ymlâ is invalid because:
Unsupported config option for services.db: âPOSTGRES_PASSWORDâ
$
$ vi docker-compose.yml
$
$
$ docker-compose up
ERROR: The Compose file â./docker-compose.ymlâ is invalid because:
Unsupported config option for services.db: âPOSTGRES_PASSWORDâ
$
$ vi docker-compose.yml
$
$ docker-compose up
ERROR: yaml.scanner.ScannerError: mapping values are not allowed here
in â./docker-compose.ymlâ, line 6, column 24
$
$ vi docker-compose.yml
$
$
$
$ docker-compose up
ERROR: The Compose file â./docker-compose.ymlâ is invalid because:
Unsupported config option for services.db: âPOSTGRES_PASSWORDâ
$
âdepends-on decides the dependency and the order of container creation and links not only does these, but also containers for the linked service will be reachable at a hostname identical to the alias, or the service name if no alias was specified.â
i.e., with links wordpress will be able to access the database using port exposed in the db image. If depends_on was used, this wouldnât be possible, but the startup order of the containers would be correct.