0
0
Microservicessystem_design~10 mins

Container networking in Microservices - Interactive Code Practice

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

Complete the code to specify the network mode for a Docker container.

Microservices
docker run --network=[1] myapp
Drag options to blanks, or click blank then click option'
Anone
Bhost
Cbridge
Doverlay
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'host' mode when isolation is needed
Confusing 'overlay' with default network mode
2fill in blank
medium

Complete the code to expose a container port to the host machine.

Microservices
docker run -p [1]:80 myapp
Drag options to blanks, or click blank then click option'
A8080
B80
C443
D3000
Attempts:
3 left
💡 Hint
Common Mistakes
Mapping the same port on host and container causing conflicts
Using a port not allowed by firewall rules
3fill in blank
hard

Fix the error in the Docker Compose service network configuration.

Microservices
services:
  web:
    image: myapp
    networks:
      - [1]
networks:
  frontend:
    driver: bridge
Drag options to blanks, or click blank then click option'
Afrontend
Bbackend
Cdefault
Dhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using a network name not defined in the networks section
Using 'host' network driver incorrectly
4fill in blank
hard

Fill both blanks to create a Docker network and connect a container to it.

Microservices
docker network [1] mynet

docker run --network=[2] myapp
Drag options to blanks, or click blank then click option'
Acreate
Bbridge
Cmynet
Dhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'bridge' as a command instead of a network type
Mismatching network names between creation and usage
5fill in blank
hard

Fill all three blanks to define a Kubernetes Pod with two containers sharing a network.

Microservices
apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: app
    image: myapp
    ports:
    - containerPort: [1]
  - name: sidecar
    image: sidecar
    ports:
    - containerPort: [2]
  [3]
Drag options to blanks, or click blank then click option'
A80
B8080
CshareProcessNamespace: true
DhostNetwork: true
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same port for both containers causing conflicts
Omitting hostNetwork when needed for host-level networking