0
0
Dockerdevops~10 mins

Defining services in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a service named 'web' using the nginx image.

Docker
services:
  web:
    image: [1]
Drag options to blanks, or click blank then click option'
Anginx
Bmysql
Credis
Dubuntu
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a database image like mysql instead of a web server image.
Using an OS image like ubuntu which doesn't run a web server by default.
2fill in blank
medium

Complete the code to expose port 80 on the 'web' service.

Docker
services:
  web:
    image: nginx
    ports:
      - "[1]:80"
Drag options to blanks, or click blank then click option'
A8080
B443
C80
D3306
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 8080 on the host without knowing if it is intended.
Using port 443 which is for HTTPS, not HTTP.
3fill in blank
hard

Fix the error in the service definition by completing the restart policy.

Docker
services:
  web:
    image: nginx
    restart: [1]
Drag options to blanks, or click blank then click option'
Aalways
Bnever
Csometimes
Don-failure
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'sometimes' which is not a valid restart policy.
Using 'never' which disables restart.
4fill in blank
hard

Fill both blanks to define environment variables for the 'db' service.

Docker
services:
  db:
    image: mysql
    environment:
      - [1]=root
      - [2]=password123
Drag options to blanks, or click blank then click option'
AMYSQL_USER
BMYSQL_ROOT_PASSWORD
CMYSQL_PASSWORD
DMYSQL_DATABASE
Attempts:
3 left
💡 Hint
Common Mistakes
Using MYSQL_ROOT_PASSWORD for a non-root user password.
Confusing MYSQL_DATABASE with user credentials.
5fill in blank
hard

Fill all three blanks to define a volume mount for the 'web' service.

Docker
services:
  web:
    image: nginx
    volumes:
      - [1]:[2]:[3]
Drag options to blanks, or click blank then click option'
A./html
B/usr/share/nginx/html
Cro
Drw
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rw' instead of 'ro' when read-only is intended.
Swapping host and container paths.